@cryptotaxi247 / netdata-1 / commits / 476677914

remove python.d/alarms (#18290)

Ilya Mashchenko committed Aug 9, 2024 at 14:26 UTC 47667791482e57c36bd10b711ab3f04a98fd5646
7 files changed -570
CMakeLists.txt
-2
@@ -2775,7 +2775,6 @@ install(FILES src/collectors/python.d.plugin/python.d.conf
2775 DESTINATION usr/lib/netdata/conf.d)
2776
2777 install(FILES
2778 - src/collectors/python.d.plugin/alarms/alarms.conf
2778 src/collectors/python.d.plugin/am2320/am2320.conf
2779 src/collectors/python.d.plugin/anomalies/anomalies.conf
2780 src/collectors/python.d.plugin/boinc/boinc.conf
@@ -2807,7 +2806,6 @@ install(FILES
2806 DESTINATION usr/lib/netdata/conf.d/python.d)
2807
2808 install(FILES
2810 - src/collectors/python.d.plugin/alarms/alarms.chart.py
2809 src/collectors/python.d.plugin/am2320/am2320.chart.py
2810 src/collectors/python.d.plugin/anomalies/anomalies.chart.py
2811 src/collectors/python.d.plugin/boinc/boinc.chart.py
src/collectors/python.d.plugin/alarms/README.md deleted
-1
@@ -1 +0,0 @@
1 -integrations/netdata_agent_alarms.md
\ No newline at end of file
src/collectors/python.d.plugin/alarms/alarms.chart.py deleted
-95
@@ -1,95 +0,0 @@
1 -# -*- coding: utf-8 -*-
2 -# Description: alarms netdata python.d module
3 -# Author: andrewm4894
4 -# SPDX-License-Identifier: GPL-3.0-or-later
5 -
6 -from json import loads
7 -
8 -from bases.FrameworkServices.UrlService import UrlService
9 -
10 -update_every = 10
11 -disabled_by_default = True
12 -
13 -
14 -def charts_template(sm, alarm_status_chart_type='line'):
15 - order = [
16 - 'alarms',
17 - 'values'
18 - ]
19 -
20 - mappings = ', '.join(['{0}={1}'.format(k, v) for k, v in sm.items()])
21 - charts = {
22 - 'alarms': {
23 - 'options': [None, 'Alarms ({0})'.format(mappings), 'status', 'status', 'alarms.status', alarm_status_chart_type],
24 - 'lines': [],
25 - 'variables': [
26 - ['alarms_num'],
27 - ]
28 - },
29 - 'values': {
30 - 'options': [None, 'Alarm Values', 'value', 'value', 'alarms.value', 'line'],
31 - 'lines': [],
32 - }
33 - }
34 - return order, charts
35 -
36 -
37 -DEFAULT_STATUS_MAP = {'CLEAR': 0, 'WARNING': 1, 'CRITICAL': 2}
38 -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):
46 - UrlService.__init__(self, configuration=configuration, name=name)
47 - self.sm = self.configuration.get('status_map', DEFAULT_STATUS_MAP)
48 - self.alarm_status_chart_type = self.configuration.get('alarm_status_chart_type', DEFAULT_ALARM_STATUS_CHART_TYPE)
49 - self.order, self.definitions = charts_template(self.sm, self.alarm_status_chart_type)
50 - self.url = self.configuration.get('url', DEFAULT_URL)
51 - self.collect_alarm_values = bool(self.configuration.get('collect_alarm_values', DEFAULT_COLLECT_ALARM_VALUES))
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()
60 - if raw_data is None:
61 - return None
62 -
63 - raw_data = loads(raw_data)
64 - alarms = raw_data.get('alarms', {})
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)
74 - data['alarms_num'] = len(data)
75 -
76 - if self.collect_alarm_values:
77 - data_values = {'{}_value'.format(a): alarms[a]['value'] * 100 for a in alarms if 'value' in alarms[a] and alarms[a]['value'] is not None}
78 - self.update_charts('values', data_values, divisor=100)
79 - data.update(data_values)
80 -
81 - return data
82 -
83 - def update_charts(self, chart, data, algorithm='absolute', multiplier=1, divisor=1):
84 - if not self.charts:
85 - return
86 -
87 - for dim in data:
88 - if dim not in self.collected_dims[chart]:
89 - self.collected_dims[chart].add(dim)
90 - self.charts[chart].add_dimension([dim, dim, algorithm, multiplier, divisor])
91 -
92 - for dim in list(self.collected_dims[chart]):
93 - if dim not in data:
94 - self.collected_dims[chart].remove(dim)
95 - self.charts[chart].del_dimension(dim, hide=False)
src/collectors/python.d.plugin/alarms/alarms.conf deleted
-60
@@ -1,60 +0,0 @@
1 -# netdata python.d.plugin configuration for example
2 -#
3 -# This file is in YaML format. Generally the format is:
4 -#
5 -# name: value
6 -#
7 -# There are 2 sections:
8 -# - global variables
9 -# - one or more JOBS
10 -#
11 -# JOBS allow you to collect values from multiple sources.
12 -# Each source will have its own set of charts.
13 -#
14 -# JOB parameters have to be indented (using spaces only, example below).
15 -
16 -# ----------------------------------------------------------------------
17 -# Global Variables
18 -# These variables set the defaults for all JOBs, however each JOB
19 -# may define its own, overriding the defaults.
20 -
21 -# update_every sets the default data collection frequency.
22 -# If unset, the python.d.plugin default is used.
23 -# update_every: 10
24 -
25 -# priority controls the order of charts at the netdata dashboard.
26 -# Lower numbers move the charts towards the top of the page.
27 -# If unset, the default for python.d.plugin is used.
28 -# priority: 60000
29 -
30 -# penalty indicates whether to apply penalty to update_every in case of failures.
31 -# Penalty will increase every 5 failed updates in a row. Maximum penalty is 10 minutes.
32 -# penalty: yes
33 -
34 -# autodetection_retry sets the job re-check interval in seconds.
35 -# The job is not deleted if check fails.
36 -# Attempts to start the job are made once every autodetection_retry.
37 -# This feature is disabled by default.
38 -# autodetection_retry: 0
39 -
40 -# ----------------------------------------------------------------------
41 -# JOBS (data collection sources)
42 -
43 -# what url to pull data from
44 -local:
45 - url: 'http://127.0.0.1:19999/api/v1/alarms?all'
46 - # define how to map alarm status to numbers for the chart
47 - status_map:
48 - CLEAR: 0
49 - WARNING: 1
50 - CRITICAL: 2
51 - # set to true to include a chart with calculated alarm values over time
52 - collect_alarm_values: false
53 - # define the type of chart for plotting status over time e.g. 'line' or 'stacked'
54 - alarm_status_chart_type: 'line'
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: ''
src/collectors/python.d.plugin/alarms/integrations/netdata_agent_alarms.md deleted
-234
@@ -1,234 +0,0 @@
1 -<!--startmeta
2 -custom_edit_url: "https://github.com/netdata/netdata/edit/master/src/collectors/python.d.plugin/alarms/README.md"
3 -meta_yaml: "https://github.com/netdata/netdata/edit/master/src/collectors/python.d.plugin/alarms/metadata.yaml"
4 -sidebar_label: "Netdata Agent alarms"
5 -learn_status: "Published"
6 -learn_rel_path: "Collecting Metrics/Other"
7 -most_popular: False
8 -message: "DO NOT EDIT THIS FILE DIRECTLY, IT IS GENERATED BY THE COLLECTOR'S metadata.yaml FILE"
9 -endmeta-->
10 -
11 -# Netdata Agent alarms
12 -
13 -Plugin: python.d.plugin
14 -Module: alarms
15 -
16 -<img src="https://img.shields.io/badge/maintained%20by-Netdata-%2300ab44" />
17 -
18 -## Overview
19 -
20 -This collector creates an 'Alarms' menu with one line plot of `alarms.status`.
21 -
22 -
23 -Alarm status is read from the Netdata agent rest api [`/api/v1/alarms?all`](https://learn.netdata.cloud/api#/alerts/alerts1).
24 -
25 -
26 -This collector is supported on all platforms.
27 -
28 -This collector supports collecting metrics from multiple instances of this integration, including remote instances.
29 -
30 -
31 -### Default Behavior
32 -
33 -#### Auto-Detection
34 -
35 -It discovers instances of Netdata running on localhost, and gathers metrics from `http://127.0.0.1:19999/api/v1/alarms?all`. `CLEAR` status is mapped to `0`, `WARNING` to `1` and `CRITICAL` to `2`. Also, by default all alarms produced will be monitored.
36 -
37 -
38 -#### Limits
39 -
40 -The default configuration for this integration does not impose any limits on data collection.
41 -
42 -#### Performance Impact
43 -
44 -The default configuration for this integration is not expected to impose a significant performance impact on the system.
45 -
46 -
47 -## Metrics
48 -
49 -Metrics grouped by *scope*.
50 -
51 -The scope defines the instance that the metric belongs to. An instance is uniquely identified by a set of labels.
52 -
53 -
54 -
55 -### Per Netdata Agent alarms instance
56 -
57 -These metrics refer to the entire monitored application.
58 -
59 -
60 -This scope has no labels.
61 -
62 -Metrics:
63 -
64 -| Metric | Dimensions | Unit |
65 -|:------|:----------|:----|
66 -| alarms.status | a dimension per alarm representing the latest status of the alarm. | status |
67 -| alarms.values | a dimension per alarm representing the latest collected value of the alarm. | value |
68 -
69 -
70 -
71 -## Alerts
72 -
73 -There are no alerts configured by default for this integration.
74 -
75 -
76 -## Setup
77 -
78 -### Prerequisites
79 -
80 -No action required.
81 -
82 -### Configuration
83 -
84 -#### File
85 -
86 -The configuration file name for this integration is `python.d/alarms.conf`.
87 -
88 -
89 -You can edit the configuration file using the `edit-config` script from the
90 -Netdata [config directory](/docs/netdata-agent/configuration/README.md#the-netdata-config-directory).
91 -
92 -```bash
93 -cd /etc/netdata 2>/dev/null || cd /opt/netdata/etc/netdata
94 -sudo ./edit-config python.d/alarms.conf
95 -```
96 -#### Options
97 -
98 -There are 2 sections:
99 -
100 -* Global variables
101 -* One or more JOBS that can define multiple different instances to monitor.
102 -
103 -The following options can be defined globally: priority, penalty, autodetection_retry, update_every, but can also be defined per JOB to override the global values.
104 -
105 -Additionally, the following collapsed table contains all the options that can be configured inside a JOB definition.
106 -
107 -Every configuration JOB starts with a `job_name` value which will appear in the dashboard, unless a `name` parameter is specified.
108 -
109 -
110 -<details open><summary>Config options</summary>
111 -
112 -| Name | Description | Default | Required |
113 -|:----|:-----------|:-------|:--------:|
114 -| url | Netdata agent alarms endpoint to collect from. Can be local or remote so long as reachable by agent. | http://127.0.0.1:19999/api/v1/alarms?all | yes |
115 -| status_map | Mapping of alarm status to integer number that will be the metric value collected. | {"CLEAR": 0, "WARNING": 1, "CRITICAL": 2} | yes |
116 -| collect_alarm_values | set to true to include a chart with calculated alarm values over time. | no | yes |
117 -| alarm_status_chart_type | define the type of chart for plotting status over time e.g. 'line' or 'stacked'. | line | yes |
118 -| alarm_contains_words | 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. | | yes |
119 -| alarm_excludes_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. | | yes |
120 -| update_every | Sets the default data collection frequency. | 10 | no |
121 -| priority | Controls the order of charts at the netdata dashboard. | 60000 | no |
122 -| autodetection_retry | Sets the job re-check interval in seconds. | 0 | no |
123 -| penalty | Indicates whether to apply penalty to update_every in case of failures. | yes | no |
124 -| name | Job name. This value will overwrite the `job_name` value. JOBS with the same name are mutually exclusive. Only one of them will be allowed running at any time. This allows autodetection to try several alternatives and pick the one that works. | | no |
125 -
126 -</details>
127 -
128 -#### Examples
129 -
130 -##### Basic
131 -
132 -A basic example configuration.
133 -
134 -```yaml
135 -jobs:
136 - url: 'http://127.0.0.1:19999/api/v1/alarms?all'
137 -
138 -```
139 -##### Advanced
140 -
141 -An advanced example configuration with multiple jobs collecting different subsets of alarms for plotting on different charts.
142 -"ML" job will collect status and values for all alarms with "ml_" in the name. Default job will collect status for all other alarms.
143 -
144 -
145 -<details open><summary>Config</summary>
146 -
147 -```yaml
148 -ML:
149 - update_every: 5
150 - url: 'http://127.0.0.1:19999/api/v1/alarms?all'
151 - status_map:
152 - CLEAR: 0
153 - WARNING: 1
154 - CRITICAL: 2
155 - collect_alarm_values: true
156 - alarm_status_chart_type: 'stacked'
157 - alarm_contains_words: 'ml_'
158 -
159 -Default:
160 - update_every: 5
161 - url: 'http://127.0.0.1:19999/api/v1/alarms?all'
162 - status_map:
163 - CLEAR: 0
164 - WARNING: 1
165 - CRITICAL: 2
166 - collect_alarm_values: false
167 - alarm_status_chart_type: 'stacked'
168 - alarm_excludes_words: 'ml_'
169 -
170 -```
171 -</details>
172 -
173 -
174 -
175 -## Troubleshooting
176 -
177 -### Debug Mode
178 -
179 -To troubleshoot issues with the `alarms` collector, run the `python.d.plugin` with the debug option enabled. The output
180 -should give you clues as to why the collector isn't working.
181 -
182 -- Navigate to the `plugins.d` directory, usually at `/usr/libexec/netdata/plugins.d/`. If that's not the case on
183 - your system, open `netdata.conf` and look for the `plugins` setting under `[directories]`.
184 -
185 - ```bash
186 - cd /usr/libexec/netdata/plugins.d/
187 - ```
188 -
189 -- Switch to the `netdata` user.
190 -
191 - ```bash
192 - sudo -u netdata -s
193 - ```
194 -
195 -- Run the `python.d.plugin` to debug the collector:
196 -
197 - ```bash
198 - ./python.d.plugin alarms debug trace
199 - ```
200 -
201 -### Getting Logs
202 -
203 -If you're encountering problems with the `alarms` collector, follow these steps to retrieve logs and identify potential issues:
204 -
205 -- **Run the command** specific to your system (systemd, non-systemd, or Docker container).
206 -- **Examine the output** for any warnings or error messages that might indicate issues. These messages should provide clues about the root cause of the problem.
207 -
208 -#### System with systemd
209 -
210 -Use the following command to view logs generated since the last Netdata service restart:
211 -
212 -```bash
213 -journalctl _SYSTEMD_INVOCATION_ID="$(systemctl show --value --property=InvocationID netdata)" --namespace=netdata --grep alarms
214 -```
215 -
216 -#### System without systemd
217 -
218 -Locate the collector log file, typically at `/var/log/netdata/collector.log`, and use `grep` to filter for collector's name:
219 -
220 -```bash
221 -grep alarms /var/log/netdata/collector.log
222 -```
223 -
224 -**Note**: This method shows logs from all restarts. Focus on the **latest entries** for troubleshooting current issues.
225 -
226 -#### Docker Container
227 -
228 -If your Netdata runs in a Docker container named "netdata" (replace if different), use this command:
229 -
230 -```bash
231 -docker logs netdata 2>&1 | grep alarms
232 -```
233 -
234 -
src/collectors/python.d.plugin/alarms/metadata.yaml deleted
-177
@@ -1,177 +0,0 @@
1 -plugin_name: python.d.plugin
2 -modules:
3 - - meta:
4 - plugin_name: python.d.plugin
5 - module_name: alarms
6 - monitored_instance:
7 - name: Netdata Agent alarms
8 - link: /src/collectors/python.d.plugin/alarms/README.md
9 - categories:
10 - - data-collection.other
11 - icon_filename: ""
12 - related_resources:
13 - integrations:
14 - list: []
15 - info_provided_to_referring_integrations:
16 - description: ""
17 - keywords:
18 - - alarms
19 - - netdata
20 - most_popular: false
21 - overview:
22 - data_collection:
23 - metrics_description: |
24 - This collector creates an 'Alarms' menu with one line plot of `alarms.status`.
25 - method_description: |
26 - Alarm status is read from the Netdata agent rest api [`/api/v1/alarms?all`](https://learn.netdata.cloud/api#/alerts/alerts1).
27 - supported_platforms:
28 - include: []
29 - exclude: []
30 - multi_instance: true
31 - additional_permissions:
32 - description: ""
33 - default_behavior:
34 - auto_detection:
35 - description: |
36 - It discovers instances of Netdata running on localhost, and gathers metrics from `http://127.0.0.1:19999/api/v1/alarms?all`. `CLEAR` status is mapped to `0`, `WARNING` to `1` and `CRITICAL` to `2`. Also, by default all alarms produced will be monitored.
37 - limits:
38 - description: ""
39 - performance_impact:
40 - description: ""
41 - setup:
42 - prerequisites:
43 - list: []
44 - configuration:
45 - file:
46 - name: python.d/alarms.conf
47 - description: ""
48 - options:
49 - description: |
50 - There are 2 sections:
51 -
52 - * Global variables
53 - * One or more JOBS that can define multiple different instances to monitor.
54 -
55 - The following options can be defined globally: priority, penalty, autodetection_retry, update_every, but can also be defined per JOB to override the global values.
56 -
57 - Additionally, the following collapsed table contains all the options that can be configured inside a JOB definition.
58 -
59 - Every configuration JOB starts with a `job_name` value which will appear in the dashboard, unless a `name` parameter is specified.
60 - folding:
61 - title: Config options
62 - enabled: true
63 - list:
64 - - name: url
65 - description: Netdata agent alarms endpoint to collect from. Can be local or remote so long as reachable by agent.
66 - default_value: http://127.0.0.1:19999/api/v1/alarms?all
67 - required: true
68 - - name: status_map
69 - description: Mapping of alarm status to integer number that will be the metric value collected.
70 - default_value: '{"CLEAR": 0, "WARNING": 1, "CRITICAL": 2}'
71 - required: true
72 - - name: collect_alarm_values
73 - description: set to true to include a chart with calculated alarm values over time.
74 - default_value: false
75 - required: true
76 - - name: alarm_status_chart_type
77 - description: define the type of chart for plotting status over time e.g. 'line' or 'stacked'.
78 - default_value: "line"
79 - required: true
80 - - name: alarm_contains_words
81 - description: >
82 - 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.
83 - default_value: ""
84 - required: true
85 - - name: alarm_excludes_words
86 - description: >
87 - 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.
88 - default_value: ""
89 - required: true
90 - - name: update_every
91 - description: Sets the default data collection frequency.
92 - default_value: 10
93 - required: false
94 - - name: priority
95 - description: Controls the order of charts at the netdata dashboard.
96 - default_value: 60000
97 - required: false
98 - - name: autodetection_retry
99 - description: Sets the job re-check interval in seconds.
100 - default_value: 0
101 - required: false
102 - - name: penalty
103 - description: Indicates whether to apply penalty to update_every in case of failures.
104 - default_value: yes
105 - required: false
106 - - name: name
107 - description: Job name. This value will overwrite the `job_name` value. JOBS with the same name are mutually exclusive. Only one of them will be allowed running at any time. This allows autodetection to try several alternatives and pick the one that works.
108 - default_value: ""
109 - required: false
110 - examples:
111 - folding:
112 - enabled: true
113 - title: Config
114 - list:
115 - - name: Basic
116 - folding:
117 - enabled: false
118 - description: A basic example configuration.
119 - config: |
120 - jobs:
121 - url: 'http://127.0.0.1:19999/api/v1/alarms?all'
122 - - name: Advanced
123 - folding:
124 - enabled: true
125 - description: |
126 - An advanced example configuration with multiple jobs collecting different subsets of alarms for plotting on different charts.
127 - "ML" job will collect status and values for all alarms with "ml_" in the name. Default job will collect status for all other alarms.
128 - config: |
129 - ML:
130 - update_every: 5
131 - url: 'http://127.0.0.1:19999/api/v1/alarms?all'
132 - status_map:
133 - CLEAR: 0
134 - WARNING: 1
135 - CRITICAL: 2
136 - collect_alarm_values: true
137 - alarm_status_chart_type: 'stacked'
138 - alarm_contains_words: 'ml_'
139 -
140 - Default:
141 - update_every: 5
142 - url: 'http://127.0.0.1:19999/api/v1/alarms?all'
143 - status_map:
144 - CLEAR: 0
145 - WARNING: 1
146 - CRITICAL: 2
147 - collect_alarm_values: false
148 - alarm_status_chart_type: 'stacked'
149 - alarm_excludes_words: 'ml_'
150 - troubleshooting:
151 - problems:
152 - list: []
153 - alerts: []
154 - metrics:
155 - folding:
156 - title: Metrics
157 - enabled: false
158 - description: ""
159 - availability: []
160 - scopes:
161 - - name: global
162 - description: |
163 - These metrics refer to the entire monitored application.
164 - labels: []
165 - metrics:
166 - - name: alarms.status
167 - description: Alarms ({status mapping})
168 - unit: "status"
169 - chart_type: line
170 - dimensions:
171 - - name: a dimension per alarm representing the latest status of the alarm.
172 - - name: alarms.values
173 - description: Alarm Values
174 - unit: "value"
175 - chart_type: line
176 - dimensions:
177 - - name: a dimension per alarm representing the latest collected value of the alarm.
src/collectors/python.d.plugin/python.d.conf
-1
@@ -25,7 +25,6 @@ gc_run: yes
25 ## Garbage collection interval in seconds. Default is 300.
26 gc_interval: 300
27
28 -# alarms: yes
28 # am2320: yes
29 # anomalies: no
30 # boinc: yes