Skip to content

Commit

Permalink
Merge pull request #304 from JeffAshton/zabbix-timezones
Browse files Browse the repository at this point in the history
Fixing zabbix timezone code
  • Loading branch information
jertel authored Jun 29, 2021
2 parents e1231c2 + 7826bf9 commit f1a5666
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions elastalert/alerters/zabbix.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def __init__(self, *args):
self.zbx_key = self.rule.get('zbx_key', None)
self.timestamp_field = self.rule.get('timestamp_field', '@timestamp')
self.timestamp_type = self.rule.get('timestamp_type', 'iso')
self.timestamp_strptime = self.rule.get('timestamp_strptime', '%Y-%m-%dT%H:%M:%S.%fZ')
self.timestamp_strptime = self.rule.get('timestamp_strptime', '%Y-%m-%dT%H:%M:%S.%f%z')

# Alert is called
def alert(self, matches):
Expand All @@ -72,10 +72,10 @@ def alert(self, matches):
else:
try:
ts_epoch = int(datetime.strptime(match[self.timestamp_field], self.timestamp_strptime)
.strftime('%s'))
.timestamp())
except ValueError:
ts_epoch = int(datetime.strptime(match[self.timestamp_field], '%Y-%m-%dT%H:%M:%SZ')
.strftime('%s'))
ts_epoch = int(datetime.strptime(match[self.timestamp_field], '%Y-%m-%dT%H:%M:%S%z')
.timestamp())
zm.append(ZabbixMetric(host=self.zbx_host, key=self.zbx_key, value='1', clock=ts_epoch))

try:
Expand Down

0 comments on commit f1a5666

Please sign in to comment.