0
0
Fork 0
mirror of https://github.com/alerta/alerta.git synced 2025-02-19 11:43:52 +00:00
alerta_alerta/alerta/webhooks/graylog.py

30 lines
1,009 B
Python
Raw Normal View History

from typing import Any, Dict
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
JSON = Dict[str, Any]
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
"""
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)