Skip to content

Commit

Permalink
Make logging to InfluxDB optional
Browse files Browse the repository at this point in the history
  • Loading branch information
ashleykleynhans committed Mar 9, 2023
1 parent ef83bbd commit 43262d0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,10 @@ def send_slack_notification(sns_message):

def influxdb_log(message, ec2_instance):
try:
if 'detail-type' in message and message['detail-type'] == 'EC2 Spot Instance Interruption Warning':
print('Logging to InfluxDB')
if 'influxdb' not in config:
return

if 'detail-type' in message and message['detail-type'] == 'EC2 Spot Instance Interruption Warning':
if message['region'] in config['environments']:
environment = config['environments'][message['region']]
influxdb_config = config['influxdb'][environment]
Expand All @@ -284,6 +285,9 @@ def influxdb_log(message, ec2_instance):
if tag['Key'] == 'aws:autoscaling:groupName':
asg_name = tag['Value']


print('Logging to InfluxDB')

client = InfluxDBClient(
url=influxdb_config['url'],
token=influxdb_config['token'],
Expand Down

0 comments on commit 43262d0

Please sign in to comment.