Merge "[Trivial] Improve alarm reason text"
This commit is contained in:
commit
112250e14e
@ -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 <id=%(id)s,event_type=%(event_type)s> hits the '
|
||||
'query <query=%(alarm_query)s>.') %
|
||||
{'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)
|
||||
|
@ -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 <id=%(e)s,event_type=%(type)s> hits the '
|
||||
'query <query=%(query)s>.') % {
|
||||
'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,
|
||||
|
Loading…
Reference in New Issue
Block a user