@cryptotaxi247 / netdata-1 / commits / 4453613cb

alarms collector: ability to exclude certain alarms via config (#13701)

alarms collector: ability to exclude certain alarms via config

Andrew Maguire committed Sep 22, 2022 at 14:50 UTC 4453613cba6d939f74e982c1d0e8d85cef8bd6be
3 files changed +12
collectors/python.d.plugin/alarms/README.md
+3
@@ -58,6 +58,9 @@ local:
58 # a "," separated list of words you want to filter alarm names for. For example 'cpu,load' would filter for only
59 # alarms with "cpu" or "load" in alarm name. Default includes all.
60 alarm_contains_words: ''
61 + # a "," separated list of words you want to exclude based on alarm name. For example 'cpu,load' would exclude
62 + # all alarms with "cpu" or "load" in alarm name. Default excludes None.
63 + alarm_excludes_words: ''
64 ```
65
66 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`
collectors/python.d.plugin/alarms/alarms.chart.py
+6
@@ -39,6 +39,7 @@ DEFAULT_URL = 'http://127.0.0.1:19999/api/v1/alarms?all'
39 DEFAULT_COLLECT_ALARM_VALUES = False
40 DEFAULT_ALARM_STATUS_CHART_TYPE = 'line'
41 DEFAULT_ALARM_CONTAINS_WORDS = ''
42 +DEFAULT_ALARM_EXCLUDES_WORDS = ''
43
44 class Service(UrlService):
45 def __init__(self, configuration=None, name=None):
@@ -51,6 +52,8 @@ class Service(UrlService):
52 self.collected_dims = {'alarms': set(), 'values': set()}
53 self.alarm_contains_words = self.configuration.get('alarm_contains_words', DEFAULT_ALARM_CONTAINS_WORDS)
54 self.alarm_contains_words_list = [alarm_contains_word.lstrip(' ').rstrip(' ') for alarm_contains_word in self.alarm_contains_words.split(',')]
55 + self.alarm_excludes_words = self.configuration.get('alarm_excludes_words', DEFAULT_ALARM_EXCLUDES_WORDS)
56 + self.alarm_excludes_words_list = [alarm_excludes_word.lstrip(' ').rstrip(' ') for alarm_excludes_word in self.alarm_excludes_words.split(',')]
57
58 def _get_data(self):
59 raw_data = self._get_raw_data()
@@ -62,6 +65,9 @@ class Service(UrlService):
65 if self.alarm_contains_words != '':
66 alarms = {alarm_name: alarms[alarm_name] for alarm_name in alarms for alarm_contains_word in
67 self.alarm_contains_words_list if alarm_contains_word in alarm_name}
68 + if self.alarm_excludes_words != '':
69 + alarms = {alarm_name: alarms[alarm_name] for alarm_name in alarms for alarm_excludes_word in
70 + self.alarm_excludes_words_list if alarm_excludes_word not in alarm_name}
71
72 data = {a: self.sm[alarms[a]['status']] for a in alarms if alarms[a]['status'] in self.sm}
73 self.update_charts('alarms', data)
collectors/python.d.plugin/alarms/alarms.conf
+3
@@ -55,3 +55,6 @@ local:
55 # a "," separated list of words you want to filter alarm names for. For example 'cpu,load' would filter for only
56 # alarms with "cpu" or "load" in alarm name. Default includes all.
57 alarm_contains_words: ''
58 + # a "," separated list of words you want to exclude based on alarm name. For example 'cpu,load' would exclude
59 + # all alarms with "cpu" or "load" in alarm name. Default excludes None.
60 + alarm_excludes_words: ''