2018-10-10 17:52:55 +00:00
|
|
|
from typing import Any, Dict
|
2017-12-13 08:22:20 +00:00
|
|
|
|
|
|
|
from alerta.models.alert import Alert
|
2018-09-15 22:07:50 +00:00
|
|
|
|
2019-02-16 00:34:18 +00:00
|
|
|
from . import WebhookBase
|
2017-12-13 08:22:20 +00:00
|
|
|
|
2018-10-10 17:52:55 +00:00
|
|
|
JSON = Dict[str, Any]
|
2017-12-13 08:22:20 +00:00
|
|
|
|
2018-10-10 17:52:55 +00:00
|
|
|
|
2019-02-16 00:34:18 +00:00
|
|
|
class GraylogWebhook(WebhookBase):
|
|
|
|
"""
|
|
|
|
Graylog Log Management HTTP alert notifications
|
|
|
|
See http://docs.graylog.org/en/3.0/pages/streams/alerts.html#http-alert-notification
|
|
|
|
"""
|
|
|
|
|
2020-02-14 22:00:59 +00:00
|
|
|
def incoming(self, path, query_string, payload):
|
2019-02-16 00:34:18 +00:00
|
|
|
|
|
|
|
return Alert(
|
|
|
|
resource=payload['stream']['title'],
|
|
|
|
event=query_string.get('event', 'Alert'),
|
|
|
|
environment=query_string.get('environment', 'Development'),
|
|
|
|
service=query_string.get('service', 'test').split(','),
|
|
|
|
severity=query_string.get('severity', 'critical'),
|
|
|
|
value='n/a',
|
|
|
|
text=payload['check_result']['result_description'],
|
|
|
|
attributes={'checkId': payload['check_result']['triggered_condition']['id']},
|
|
|
|
origin='Graylog',
|
|
|
|
event_type=query_string.get('event_type', 'performanceAlert'),
|
|
|
|
raw_data=payload)
|