0
0
Fork 0
mirror of https://github.com/alerta/alerta.git synced 2025-02-05 22:19:45 +00:00
alerta_alerta/alerta/plugins/reject.py
2014-08-09 00:20:46 +01:00

26 lines
658 B
Python

import re
from alerta.plugins import PluginBase
ORIGIN_BLACKLIST = [
re.compile('foo/bar'),
re.compile('qux/.*')
]
class RejectPolicy(PluginBase):
def pre_receive(self, alert):
if any(regex.match(alert.origin) for regex in ORIGIN_BLACKLIST):
return "[POLICY] Alert origin '%s' has been blacklisted" % alert.origin
if alert.environment not in ['Production', 'Development']:
return "[POLICY] Alert with unsupported environment '%s' rejected" % alert.environment
if not alert.service:
return "[POLICY] Alert must define a service"
def post_receive(self, alert):
pass