Skip to content

Commit

Permalink
python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian GAULTIER committed Oct 23, 2019
1 parent cfcec50 commit 489bfc2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions elastalert/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def _create_custom_alert_text(self, event=None, alert_text_key='alert_text'):
if event is None:
event = self.match
missing = self.rule.get('alert_missing_value', '<MISSING VALUE>')
alert_text = unicode(self.rule.get(alert_text_key, ''))
alert_text = str(self.rule.get(alert_text_key, ''))

if alert_text_key+'_args' in self.rule:
alert_text_args = self.rule.get(alert_text_key+'_args')
Expand Down Expand Up @@ -159,7 +159,7 @@ def __str__(self):
if 'related_events' in self.match:
related_events = self.match['related_events']
del self.match['related_events']
alert_text_related_event_text = unicode(self.rule.get('alert_text_related_event_text', ''))
alert_text_related_event_text = str(self.rule.get('alert_text_related_event_text', ''))
if alert_text_related_event_text == '':
self.text += '\n----------------------------------------\n'
self._add_match_items()
Expand Down Expand Up @@ -2150,7 +2150,7 @@ def create_artifacts(self, match):
artifacts = []
context = {'rule': self.rule, 'match': match}
for mapping in self.rule.get('hive_observable_data_mapping', []):
for observable_type, match_data_key in mapping.iteritems():
for observable_type, match_data_key in mapping.items():
try:
artifacts.append(AlertArtifact(dataType=observable_type, data=match_data_key.format(**context)))
except KeyError:
Expand All @@ -2167,10 +2167,10 @@ def create_alert_config(self, match):

alert_config.update(self.rule.get('hive_alert_config', {}))

for alert_config_field, alert_config_value in alert_config.iteritems():
for alert_config_field, alert_config_value in alert_config.items():
if alert_config_field == 'customFields':
custom_fields = CustomFieldHelper()
for cf_key, cf_value in alert_config_value.iteritems():
for cf_key, cf_value in alert_config_value.items():
try:
func = getattr(custom_fields, 'add_{}'.format(cf_value['type']))
except AttributeError:
Expand Down

0 comments on commit 489bfc2

Please sign in to comment.