0
0
Fork 0
mirror of https://github.com/alerta/alerta.git synced 2025-02-04 21:58:31 +00:00
alerta_alerta/alerta/plugins/acked_by.py
2019-05-20 15:15:13 +02:00

37 lines
1 KiB
Python

import logging
from flask import g
from alerta.plugins import PluginBase
LOG = logging.getLogger('alerta.plugins')
class AckedBy(PluginBase):
"""
Add "acked-by" attribute to alerts with login id of the operator when
an alert is acked and automatically watch the alert. Unset the attribute
when alert is un-acked. Un-watching requires manual intervention.
To display the "acked-by" attribute in the alert summary add "acked-by"
to the list of alert attributes in the COLUMNS server setting.
"""
def pre_receive(self, alert, **kwargs):
return alert
def post_receive(self, alert, **kwargs):
return
def status_change(self, alert, status, text, **kwargs):
return
def take_action(self, alert, action, text, **kwargs):
if action == 'ack':
watch = 'watch:' + g.login
alert.tags.append(watch)
alert.attributes['acked-by'] = g.login
if action == 'unack':
alert.attributes['acked-by'] = None
return alert