forked from alerta/alerta
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheartbeat.py
More file actions
37 lines (27 loc) · 998 Bytes
/
heartbeat.py
File metadata and controls
37 lines (27 loc) · 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import logging
from alerta.exceptions import HeartbeatReceived
from alerta.models.heartbeat import Heartbeat
from alerta.plugins import PluginBase
LOG = logging.getLogger('alerta.plugins')
class HeartbeatReceiver(PluginBase):
"""
Default heartbeat receiver intercepts alerts with event='Heartbeat', converts
them into heartbeats and will return a 202 Accept HTTP status code.
"""
def pre_receive(self, alert, **kwargs):
if alert.event == 'Heartbeat':
hb = Heartbeat(
origin=alert.origin,
tags=alert.tags,
timeout=alert.timeout,
customer=alert.customer
)
r = hb.create()
raise HeartbeatReceived(r.id)
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):
raise NotImplementedError