Commit 734caf2
committed
Fix the use of timestamps in the Jira ticket titles
This has come about because we currently use records which have timestamps like:
```
"@timestamp": {
"min": "2020-10-03T07:05:01.987Z",
"max": "2020-10-05T07:05:09.572Z"
},
```
These work fine with the `timestamp_field` set to `@timestamp.min`.
However, when we try to create a Jira alert using ElastAlert from these, we run
into a Python error:
```
File "/usr/local/lib/python3.6/site-packages/elastalert/alerts.py", line 875, in create_default_title,
title += ' - %s' % (pretty_ts(matches[0][self.rule['timestamp_field']], self.rule.get('use_local_time'))), KeyError: '@timestamp.min'
```
This is because matches[0][self.rule['timestamp_field']] attempts to access
the `timestamp_field` directly rather than using a `get()`.
The proposed fix will not change any existing behaviour, but will skip the addition
of a timestamp to the ticket title if the required field doesn't exist, rather than
throwing an error and disabling the rule.1 parent ea62cf4 commit 734caf2
1 file changed
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
868 | 868 | | |
869 | 869 | | |
870 | 870 | | |
871 | | - | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
872 | 874 | | |
873 | 875 | | |
874 | 876 | | |
| |||
0 commit comments