0
0
Fork 0
mirror of https://github.com/alerta/alerta.git synced 2025-02-11 08:18:53 +00:00
alerta_alerta/examples/plugins/routing/routing.py
Nick Satterly cd0dfbe088
Type annotate plugins and webhooks (#700)
* Type annotate plugins (part 1)

* Type annotate webhooks (part 2)
2018-10-10 19:52:55 +02:00

43 lines
1.1 KiB
Python

"""
Example Routing Rules Plugin - Customer-based Escalation/Notification
Use different notification paths for different customers. ie. PagerDuty
for Tier 1 customers, Slack for Tier 2 and nothing for Tier 3 customers.
"""
TIER_ONE_CUSTOMERS = [
'Tyrell Corporation',
'Cyberdyne Systems',
'Weyland-Yutani',
'Zorin Enterprises'
]
TIER_TWO_CUSTOMERS = [
'Soylent Corporation',
'Omni Consumer Products',
'Dolmansaxlil Shoe Corporation'
]
def rules(alert, plugins):
if alert.customer in TIER_ONE_CUSTOMERS:
# Tier 1 customer SLA needs PagerDuty to manage escalation
return [
plugins['reject'],
plugins['blackout'],
plugins['pagerduty']
]
elif alert.customer in TIER_TWO_CUSTOMERS:
# Tier 2 customers handled via Slack
return [
plugins['reject'],
plugins['blackout'],
plugins['slack']
]
else:
# Tier 3 customers get "best effort"
return [
plugins['reject'],
plugins['blackout']
]