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_config import cfg
|
||||||
from oslo_log import log
|
from oslo_log import log
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
from oslo_utils import fnmatch
|
from oslo_utils import fnmatch
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
import six
|
import six
|
||||||
@ -248,9 +249,12 @@ class EventAlarmEvaluator(evaluator.Evaluator):
|
|||||||
"""Update alarm state and fire alarm via alarm notifier."""
|
"""Update alarm state and fire alarm via alarm notifier."""
|
||||||
|
|
||||||
state = evaluator.ALARM
|
state = evaluator.ALARM
|
||||||
reason = (_('Event (message_id=%(message)s) hit the query of alarm '
|
reason = (_('Event <id=%(id)s,event_type=%(event_type)s> hits the '
|
||||||
'(id=%(alarm)s)') %
|
'query <query=%(alarm_query)s>.') %
|
||||||
{'message': event.id, 'alarm': alarm.id})
|
{'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}
|
reason_data = {'type': 'event', 'event': event.obj}
|
||||||
always_record = alarm.obj.repeat_actions
|
always_record = alarm.obj.repeat_actions
|
||||||
self._refresh(alarm.obj, state, reason, reason_data, always_record)
|
self._refresh(alarm.obj, state, reason, reason_data, always_record)
|
||||||
|
@ -19,6 +19,7 @@ import six
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
from oslo_serialization import jsonutils
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
|
|
||||||
from aodh import evaluator
|
from aodh import evaluator
|
||||||
@ -122,9 +123,12 @@ class TestEventAlarmEvaluate(base.TestEvaluatorBase):
|
|||||||
alarm = n['alarm']
|
alarm = n['alarm']
|
||||||
event = n['event']
|
event = n['event']
|
||||||
previous = n.get('previous', evaluator.UNKNOWN)
|
previous = n.get('previous', evaluator.UNKNOWN)
|
||||||
reason = ('Event (message_id=%(e)s) hit the query of alarm '
|
reason = ('Event <id=%(e)s,event_type=%(type)s> hits the '
|
||||||
'(id=%(a)s)' %
|
'query <query=%(query)s>.') % {
|
||||||
{'e': event['message_id'], 'a': alarm.alarm_id})
|
'e': event['message_id'],
|
||||||
|
'type': event['event_type'],
|
||||||
|
'query': jsonutils.dumps(alarm.rule['query'],
|
||||||
|
sort_keys=True)}
|
||||||
data = {'type': 'event', 'event': event}
|
data = {'type': 'event', 'event': event}
|
||||||
expected = dict(alarm_id=alarm.alarm_id,
|
expected = dict(alarm_id=alarm.alarm_id,
|
||||||
state=evaluator.ALARM,
|
state=evaluator.ALARM,
|
||||||
|
Loading…
Reference in New Issue
Block a user