-
Notifications
You must be signed in to change notification settings - Fork 173
/
Copy pathalerta_fail2ban.py
33 lines (27 loc) · 973 Bytes
/
alerta_fail2ban.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import json
from alerta.models.alert import Alert
from alerta.webhooks import WebhookBase
class Fail2BanWebhook(WebhookBase):
def incoming(self, query_string, payload):
# Default parameters
environment = 'Production'
severity = 'security'
group = 'Fail2Ban'
text = ''
tags = []
attributes = {}
origin = ''
return Alert(
resource=payload['resource'],
event=payload['event'],
environment=payload.get('environment', environment),
severity=payload.get('severity', severity),
service=['fail2ban'],
group=payload.get('group', group),
value='BAN',
text=payload.get('message', text),
tags=payload.get('tags', tags),
attributes=payload.get('attributes', attributes),
origin=payload.get('hostname', origin),
raw_data=json.dumps(payload, indent=4)
)