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/pingdom.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

42 lines
1.2 KiB
Python

from typing import Any, Dict
from alerta.app import alarm_model
from alerta.models.alert import Alert
from . import WebhookBase
JSON = Dict[str, Any]
class PingdomWebhook(WebhookBase):
"""
Pingdom state change webhook
See https://www.pingdom.com/resources/webhooks/
"""
def incoming(self, path, query_string, payload):
if payload['importance_level'] == 'HIGH':
severity = 'critical'
else:
severity = 'warning'
if payload['current_state'] == 'UP':
severity = alarm_model.DEFAULT_NORMAL_SEVERITY
return Alert(
resource=payload['check_name'],
event=payload['current_state'],
correlate=['UP', 'DOWN'],
environment='Production',
severity=severity,
service=[payload['check_type']],
group='Network',
value=payload['description'],
text='{}: {}'.format(payload['importance_level'], payload['long_description']),
tags=payload['tags'],
attributes={'checkId': payload['check_id']},
origin='Pingdom',
event_type='availabilityAlert',
raw_data=payload
)