diff --git a/aodh/evaluator/event.py b/aodh/evaluator/event.py index c38f201c1..2c800dba6 100644 --- a/aodh/evaluator/event.py +++ b/aodh/evaluator/event.py @@ -17,6 +17,7 @@ import operator from oslo_config import cfg from oslo_log import log +from oslo_serialization import jsonutils from oslo_utils import fnmatch from oslo_utils import timeutils import six @@ -248,9 +249,12 @@ class EventAlarmEvaluator(evaluator.Evaluator): """Update alarm state and fire alarm via alarm notifier.""" state = evaluator.ALARM - reason = (_('Event (message_id=%(message)s) hit the query of alarm ' - '(id=%(alarm)s)') % - {'message': event.id, 'alarm': alarm.id}) + reason = (_('Event hits the ' + 'query .') % + {'id': event.id, + 'event_type': event.get_value('event_type'), + 'alarm_query': jsonutils.dumps(alarm.obj.rule['query'], + sort_keys=True)}) reason_data = {'type': 'event', 'event': event.obj} always_record = alarm.obj.repeat_actions self._refresh(alarm.obj, state, reason, reason_data, always_record) diff --git a/aodh/tests/unit/evaluator/test_event.py b/aodh/tests/unit/evaluator/test_event.py index 5672804d2..106d39893 100644 --- a/aodh/tests/unit/evaluator/test_event.py +++ b/aodh/tests/unit/evaluator/test_event.py @@ -19,6 +19,7 @@ import six import uuid import mock +from oslo_serialization import jsonutils from oslo_utils import timeutils from aodh import evaluator @@ -122,9 +123,12 @@ class TestEventAlarmEvaluate(base.TestEvaluatorBase): alarm = n['alarm'] event = n['event'] previous = n.get('previous', evaluator.UNKNOWN) - reason = ('Event (message_id=%(e)s) hit the query of alarm ' - '(id=%(a)s)' % - {'e': event['message_id'], 'a': alarm.alarm_id}) + reason = ('Event hits the ' + 'query .') % { + 'e': event['message_id'], + 'type': event['event_type'], + 'query': jsonutils.dumps(alarm.rule['query'], + sort_keys=True)} data = {'type': 'event', 'event': event} expected = dict(alarm_id=alarm.alarm_id, state=evaluator.ALARM,