0
0
Fork 0
mirror of https://github.com/alerta/alerta.git synced 2025-01-27 18:39:04 +00:00
alerta_alerta/alerta/webhooks/graylog.py
Nick Satterly 17ef9f0ceb
Support webhooks with a subpath (#1150)
* Support webhooks with a subpath

* Add tests for webhooks with subpath
2020-02-14 23:00:59 +01:00

29 lines
1,009 B
Python

from typing import Any, Dict
from alerta.models.alert import Alert
from . import WebhookBase
JSON = Dict[str, Any]
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):
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)