forked from jertel/elastalert2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenhancements.py
25 lines (17 loc) · 832 Bytes
/
enhancements.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
# -*- coding: utf-8 -*-
from elastalert.util import pretty_ts
class BaseEnhancement(object):
""" Enhancements take a match dictionary object and modify it in some way to
enhance an alert. These are specified in each rule under the match_enhancements option.
Generally, the key value pairs in the match module will be contained in the alert body. """
def __init__(self, rule):
self.rule = rule
def process(self, match):
""" Modify the contents of match, a dictionary, in some way """
raise NotImplementedError()
class TimeEnhancement(BaseEnhancement):
def process(self, match):
match['@timestamp'] = pretty_ts(match['@timestamp'])
class DropMatchException(Exception):
""" ElastAlert will drop a match if this exception type is raised by an enhancement """
pass