-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing zabbix timezone code #304
Conversation
@@ -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') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using just Z
parses the timezone incorrectly.
@@ -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()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returns the unix epoch as a float instead of a string.
@nsano-rururu Will you please review this? My primary concern is whether the parse using %z will cause any problem if some ES clusters use a timestamp format of ...Z and others use ...+05:00. The docs for %z state it expects the latter. |
vs
|
I get a lot of my names for some reason, but I'm not sure because zabbix_basic wasn't made by me. |
My bad. This demonstrates UTC: Z
UTC: +00:00
EST
Doing just |
@nsano-rururu, the test case
test_zabbix_basic
fails if the current timezone is not UTC.