Skip to content

Commit

Permalink
Merge branch 'feature/zabbix-minio' into 'master'
Browse files Browse the repository at this point in the history
MinIO tags are now created automatically if required.

See merge request opensolutions/elastalert!6
  • Loading branch information
alvarolmedo committed Dec 11, 2019
2 parents ddac870 + c3cc8ab commit f887dc5
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions elastalert/zabbix.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,21 +150,16 @@ def alert(self, matches):
if found:
filtered_triggers.append(trigger)

# Only triggers with tags that requires updates are updated
for trigger in filtered_triggers:
update_required = False
for tag in trigger['tags']:
if tag['tag'] == 'MINIO_BUCKET' and tag['value'] != self.minio_bucket:
tag['value'] = self.minio_bucket
update_required = True

if tag['tag'] == 'MINIO_OBJECT' and tag['value'] != object_name:
tag['value'] = object_name
update_required = True

if update_required:
self.logger.info(f"Updating tags for {self.zbx_host}'s trigger: {trigger['tags']}")
self.zbx_client.trigger.update(triggerid=trigger['triggerid'], tags=trigger['tags'])
tags_index = {tag['tag']: tag['value'] for tag in trigger['tags']}

tags_index['MINIO_BUCKET'] = self.minio_bucket
tags_index['MINIO_OBJECT'] = object_name

trigger['tags'] = [{'tag': tag, 'value': value} for tag, value in tags_index.items()]

self.logger.debug(f"Updating '{self.zbx_host}'-'{trigger['description']}' tags: {trigger['tags']}")
self.zbx_client.trigger.update(triggerid=trigger['triggerid'], tags=trigger['tags'])

ZabbixSender(zabbix_server=self.zbx_sender_host, zabbix_port=self.zbx_sender_port).send(zm)

Expand Down

0 comments on commit f887dc5

Please sign in to comment.