alarms collector: ability to exclude certain alarms via config (#13701)
alarms collector: ability to exclude certain alarms via config
This commit is contained in:
parent
eddb7125fa
commit
4453613cba
|
@ -58,6 +58,9 @@ local:
|
|||
# a "," separated list of words you want to filter alarm names for. For example 'cpu,load' would filter for only
|
||||
# alarms with "cpu" or "load" in alarm name. Default includes all.
|
||||
alarm_contains_words: ''
|
||||
# a "," separated list of words you want to exclude based on alarm name. For example 'cpu,load' would exclude
|
||||
# all alarms with "cpu" or "load" in alarm name. Default excludes None.
|
||||
alarm_excludes_words: ''
|
||||
```
|
||||
|
||||
It will default to pulling all alarms at each time step from the Netdata rest api at `http://127.0.0.1:19999/api/v1/alarms?all`
|
||||
|
|
|
@ -39,6 +39,7 @@ DEFAULT_URL = 'http://127.0.0.1:19999/api/v1/alarms?all'
|
|||
DEFAULT_COLLECT_ALARM_VALUES = False
|
||||
DEFAULT_ALARM_STATUS_CHART_TYPE = 'line'
|
||||
DEFAULT_ALARM_CONTAINS_WORDS = ''
|
||||
DEFAULT_ALARM_EXCLUDES_WORDS = ''
|
||||
|
||||
class Service(UrlService):
|
||||
def __init__(self, configuration=None, name=None):
|
||||
|
@ -51,6 +52,8 @@ class Service(UrlService):
|
|||
self.collected_dims = {'alarms': set(), 'values': set()}
|
||||
self.alarm_contains_words = self.configuration.get('alarm_contains_words', DEFAULT_ALARM_CONTAINS_WORDS)
|
||||
self.alarm_contains_words_list = [alarm_contains_word.lstrip(' ').rstrip(' ') for alarm_contains_word in self.alarm_contains_words.split(',')]
|
||||
self.alarm_excludes_words = self.configuration.get('alarm_excludes_words', DEFAULT_ALARM_EXCLUDES_WORDS)
|
||||
self.alarm_excludes_words_list = [alarm_excludes_word.lstrip(' ').rstrip(' ') for alarm_excludes_word in self.alarm_excludes_words.split(',')]
|
||||
|
||||
def _get_data(self):
|
||||
raw_data = self._get_raw_data()
|
||||
|
@ -62,6 +65,9 @@ class Service(UrlService):
|
|||
if self.alarm_contains_words != '':
|
||||
alarms = {alarm_name: alarms[alarm_name] for alarm_name in alarms for alarm_contains_word in
|
||||
self.alarm_contains_words_list if alarm_contains_word in alarm_name}
|
||||
if self.alarm_excludes_words != '':
|
||||
alarms = {alarm_name: alarms[alarm_name] for alarm_name in alarms for alarm_excludes_word in
|
||||
self.alarm_excludes_words_list if alarm_excludes_word not in alarm_name}
|
||||
|
||||
data = {a: self.sm[alarms[a]['status']] for a in alarms if alarms[a]['status'] in self.sm}
|
||||
self.update_charts('alarms', data)
|
||||
|
|
|
@ -55,3 +55,6 @@ local:
|
|||
# a "," separated list of words you want to filter alarm names for. For example 'cpu,load' would filter for only
|
||||
# alarms with "cpu" or "load" in alarm name. Default includes all.
|
||||
alarm_contains_words: ''
|
||||
# a "," separated list of words you want to exclude based on alarm name. For example 'cpu,load' would exclude
|
||||
# all alarms with "cpu" or "load" in alarm name. Default excludes None.
|
||||
alarm_excludes_words: ''
|
||||
|
|
Loading…
Reference in New Issue