0
0
Fork 0
mirror of https://github.com/alerta/alerta.git synced 2025-01-27 02:28:49 +00:00
alerta_alerta/alerta/webhooks/riemann.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

30 lines
869 B
Python

from typing import Any, Dict
from alerta.models.alert import Alert
from . import WebhookBase
JSON = Dict[str, Any]
class RiemannWebhook(WebhookBase):
"""
Riemann HTTP client
http://riemann.io/clients.html
"""
def incoming(self, path, query_string, payload):
return Alert(
resource='{}-{}'.format(payload['host'], payload['service']),
event=payload.get('event', payload['service']),
environment=payload.get('environment', 'Production'),
severity=payload.get('state', 'unknown'),
service=[payload['service']],
group=payload.get('group', 'Performance'),
text=payload.get('description', None),
value=payload.get('metric', None),
tags=payload.get('tags', None),
origin='Riemann',
raw_data=payload
)