summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Maguire <andrewm4894@gmail.com>2022-09-22 14:50:55 +0100
committerGitHub <noreply@github.com>2022-09-22 14:50:55 +0100
commit4453613cba6d939f74e982c1d0e8d85cef8bd6be (patch)
treef133699421e276f97e1dcbb06389aba070336b1b
parenteddb7125faa609d87248036e8b8533b8bdd00621 (diff)
alarms collector: ability to exclude certain alarms via config (#13701)
alarms collector: ability to exclude certain alarms via config
-rw-r--r--collectors/python.d.plugin/alarms/README.md3
-rw-r--r--collectors/python.d.plugin/alarms/alarms.chart.py6
-rw-r--r--collectors/python.d.plugin/alarms/alarms.conf3
3 files changed, 12 insertions, 0 deletions
diff --git a/collectors/python.d.plugin/alarms/README.md b/collectors/python.d.plugin/alarms/README.md
index ee1e599719..8dc666f5bb 100644
--- a/collectors/python.d.plugin/alarms/README.md
+++ b/collectors/python.d.plugin/alarms/README.md
@@ -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`
diff --git a/collectors/python.d.plugin/alarms/alarms.chart.py b/collectors/python.d.plugin/alarms/alarms.chart.py
index 314b0e7a83..d194273581 100644
--- a/collectors/python.d.plugin/alarms/alarms.chart.py
+++ b/collectors/python.d.plugin/alarms/alarms.chart.py
@@ -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)
diff --git a/collectors/python.d.plugin/alarms/alarms.conf b/collectors/python.d.plugin/alarms/alarms.conf
index cd48d44113..06d76c3b34 100644
--- a/collectors/python.d.plugin/alarms/alarms.conf
+++ b/collectors/python.d.plugin/alarms/alarms.conf
@@ -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: ''