Remove family from alerts (#16025)
* remove loading and storing families from alert configs * remove families from silencers * remove from alarm log * start remove from alarm-notify.sh.in * fix test alarm * rebase * remove from api/v1/alarm_log * remove from alert stream * remove from config stream * remove from more * remove from swagger for health api * revert md changes * remove from health cmd api test
Emmanuel Vasilakis committed
Oct 6, 2023 at 00:57 UTC
9493fa868256c66478e5191658db5daa24e74336
26 files changed
+148
-335
aclk/schema-wrappers/alarm_config.cc
-16
@@ -15,28 +15,22 @@ void destroy_aclk_alarm_configuration(struct aclk_alarm_configuration *cfg)
15
freez(cfg->alarm);
16
freez(cfg->tmpl);
17
freez(cfg->on_chart);
18
-
18
freez(cfg->classification);
19
freez(cfg->type);
20
freez(cfg->component);
22
-
21
freez(cfg->os);
22
freez(cfg->hosts);
23
freez(cfg->plugin);
24
freez(cfg->module);
25
freez(cfg->charts);
28
- freez(cfg->families);
26
freez(cfg->lookup);
27
freez(cfg->every);
28
freez(cfg->units);
32
-
29
freez(cfg->green);
30
freez(cfg->red);
35
-
31
freez(cfg->calculation_expr);
32
freez(cfg->warning_expr);
33
freez(cfg->critical_expr);
39
-
34
freez(cfg->recipient);
35
freez(cfg->exec);
36
freez(cfg->delay);
@@ -44,11 +38,9 @@ void destroy_aclk_alarm_configuration(struct aclk_alarm_configuration *cfg)
38
freez(cfg->info);
39
freez(cfg->options);
40
freez(cfg->host_labels);
47
-
41
freez(cfg->p_db_lookup_dimensions);
42
freez(cfg->p_db_lookup_method);
43
freez(cfg->p_db_lookup_options);
51
-
44
freez(cfg->chart_labels);
45
freez(cfg->summary);
46
}
@@ -66,14 +58,12 @@ char *generate_provide_alarm_configuration(size_t *len, struct provide_alarm_con
58
cfg->set_template_(data->cfg.tmpl);
59
if(data->cfg.on_chart)
60
cfg->set_on_chart(data->cfg.on_chart);
69
-
61
if (data->cfg.classification)
62
cfg->set_classification(data->cfg.classification);
63
if (data->cfg.type)
64
cfg->set_type(data->cfg.type);
65
if (data->cfg.component)
66
cfg->set_component(data->cfg.component);
76
-
67
if (data->cfg.os)
68
cfg->set_os(data->cfg.os);
69
if (data->cfg.hosts)
@@ -84,27 +74,22 @@ char *generate_provide_alarm_configuration(size_t *len, struct provide_alarm_con
74
cfg->set_module(data->cfg.module);
75
if(data->cfg.charts)
76
cfg->set_charts(data->cfg.charts);
87
- if(data->cfg.families)
88
- cfg->set_families(data->cfg.families);
77
if(data->cfg.lookup)
78
cfg->set_lookup(data->cfg.lookup);
79
if(data->cfg.every)
80
cfg->set_every(data->cfg.every);
81
if(data->cfg.units)
82
cfg->set_units(data->cfg.units);
95
-
83
if (data->cfg.green)
84
cfg->set_green(data->cfg.green);
85
if (data->cfg.red)
86
cfg->set_red(data->cfg.red);
100
-
87
if (data->cfg.calculation_expr)
88
cfg->set_calculation_expr(data->cfg.calculation_expr);
89
if (data->cfg.warning_expr)
90
cfg->set_warning_expr(data->cfg.warning_expr);
91
if (data->cfg.critical_expr)
92
cfg->set_critical_expr(data->cfg.critical_expr);
107
-
93
if (data->cfg.recipient)
94
cfg->set_recipient(data->cfg.recipient);
95
if (data->cfg.exec)
@@ -132,7 +117,6 @@ char *generate_provide_alarm_configuration(size_t *len, struct provide_alarm_con
117
118
if (data->cfg.chart_labels)
119
cfg->set_chart_labels(data->cfg.chart_labels);
135
-
120
if (data->cfg.summary)
121
cfg->set_summary(data->cfg.summary);
122
aclk/schema-wrappers/alarm_config.h
-1
@@ -24,7 +24,6 @@ struct aclk_alarm_configuration {
24
char *plugin;
25
char *module;
26
char *charts;
27
- char *families;
27
char *lookup;
28
char *every;
29
char *units;
aclk/schema-wrappers/alarm_stream.cc
-14
@@ -66,11 +66,8 @@ static alarms::v1::AlarmStatus aclk_alarm_status_to_proto(enum aclk_alarm_status
66
67
void destroy_alarm_log_entry(struct alarm_log_entry *entry)
68
{
69
- //freez(entry->node_id);
70
- //freez(entry->claim_id);
69
freez(entry->chart);
70
freez(entry->name);
73
- freez(entry->family);
71
freez(entry->config_hash);
72
freez(entry->timezone);
73
freez(entry->exec_path);
@@ -89,32 +86,21 @@ static void fill_alarm_log_entry(struct alarm_log_entry *data, AlarmLogEntry *pr
86
{
87
proto->set_node_id(data->node_id);
88
proto->set_claim_id(data->claim_id);
92
-
89
proto->set_chart(data->chart);
90
proto->set_name(data->name);
95
- if (data->family)
96
- proto->set_family(data->family);
97
-
91
proto->set_when(data->when);
99
-
92
proto->set_config_hash(data->config_hash);
101
-
93
proto->set_utc_offset(data->utc_offset);
94
proto->set_timezone(data->timezone);
104
-
95
proto->set_exec_path(data->exec_path);
96
proto->set_conf_source(data->conf_source);
97
proto->set_command(data->command);
108
-
98
proto->set_duration(data->duration);
99
proto->set_non_clear_duration(data->non_clear_duration);
111
-
112
-
100
proto->set_status(aclk_alarm_status_to_proto(data->status));
101
proto->set_old_status(aclk_alarm_status_to_proto(data->old_status));
102
proto->set_delay(data->delay);
103
proto->set_delay_up_to_timestamp(data->delay_up_to_timestamp);
117
-
104
proto->set_last_repeat(data->last_repeat);
105
proto->set_silenced(data->silenced);
106
database/rrd.h
-2
@@ -992,7 +992,6 @@ struct alarm_entry {
992
STRING *chart;
993
STRING *chart_context;
994
STRING *chart_name;
995
- STRING *family;
995
996
STRING *classification;
997
STRING *component;
@@ -1037,7 +1036,6 @@ struct alarm_entry {
1036
#define ae_chart_id(ae) string2str((ae)->chart)
1037
#define ae_chart_name(ae) string2str((ae)->chart_name)
1038
#define ae_chart_context(ae) string2str((ae)->chart_context)
1040
-#define ae_family(ae) string2str((ae)->family)
1039
#define ae_classification(ae) string2str((ae)->classification)
1040
#define ae_exec(ae) string2str((ae)->exec)
1041
#define ae_recipient(ae) string2str((ae)->recipient)
database/rrdcalc.c
-2
@@ -310,7 +310,6 @@ static void rrdcalc_link_to_rrdset(RRDSET *st, RRDCALC *rc) {
310
rc->rrdset->id,
311
rc->rrdset->context,
312
rc->rrdset->name,
313
- rc->rrdset->family,
313
rc->classification,
314
rc->component,
315
rc->type,
@@ -357,7 +356,6 @@ static void rrdcalc_unlink_from_rrdset(RRDCALC *rc, bool having_ll_wrlock) {
356
rc->rrdset->id,
357
rc->rrdset->context,
358
rc->rrdset->name,
360
- rc->rrdset->family,
359
rc->classification,
360
rc->component,
361
rc->type,
database/rrdcalc.h
-1
@@ -196,7 +196,6 @@ struct alert_config {
196
STRING *os;
197
STRING *host;
198
STRING *on;
199
- STRING *families;
199
STRING *plugin;
200
STRING *module;
201
STRING *charts;
database/rrdcalctemplate.c
+1
-11
@@ -37,9 +37,6 @@ bool rrdcalctemplate_check_rrdset_conditions(RRDCALCTEMPLATE *rt, RRDSET *st, RR
37
if (rt->charts_pattern && !simple_pattern_matches_string(rt->charts_pattern, st->name) && !simple_pattern_matches_string(rt->charts_pattern, st->id))
38
return false;
39
40
- if (rt->family_pattern && !simple_pattern_matches_string(rt->family_pattern, st->family))
41
- return false;
42
-
40
if (rt->module_pattern && !simple_pattern_matches_string(rt->module_pattern, st->module_name))
41
return false;
42
@@ -100,9 +97,6 @@ static void rrdcalctemplate_free_internals(RRDCALCTEMPLATE *rt) {
97
expression_free(rt->warning);
98
expression_free(rt->critical);
99
103
- string_freez(rt->family_match);
104
- simple_pattern_free(rt->family_pattern);
105
-
100
string_freez(rt->plugin_match);
101
simple_pattern_free(rt->plugin_pattern);
102
@@ -217,10 +211,6 @@ inline void rrdcalctemplate_delete_all(RRDHOST *host) {
211
}
212
213
#define RRDCALCTEMPLATE_MAX_KEY_SIZE 1024
220
-static size_t rrdcalctemplate_key(char *dst, size_t dst_len, const char *name, const char *family_match) {
221
- return snprintfz(dst, dst_len, "%s/%s", name, (family_match && *family_match)?family_match:"*");
222
-}
223
-
214
void rrdcalctemplate_add_from_config(RRDHOST *host, RRDCALCTEMPLATE *rt) {
215
if(unlikely(!rt->context)) {
216
netdata_log_error("Health configuration for template '%s' does not have a context", rrdcalctemplate_name(rt));
@@ -238,7 +228,7 @@ void rrdcalctemplate_add_from_config(RRDHOST *host, RRDCALCTEMPLATE *rt) {
228
}
229
230
char key[RRDCALCTEMPLATE_MAX_KEY_SIZE + 1];
241
- size_t key_len = rrdcalctemplate_key(key, RRDCALCTEMPLATE_MAX_KEY_SIZE, rrdcalctemplate_name(rt), rrdcalctemplate_family_match(rt));
231
+ size_t key_len = snprintfz(key, RRDCALCTEMPLATE_MAX_KEY_SIZE, "%s", rrdcalctemplate_name(rt));
232
233
bool added = false;
234
dictionary_set_advanced(host->rrdcalctemplate_root_index, key, (ssize_t)(key_len + 1), rt, sizeof(*rt), &added);
database/rrdcalctemplate.h
-4
@@ -22,9 +22,6 @@ struct rrdcalctemplate {
22
23
STRING *context;
24
25
- STRING *family_match;
26
- SIMPLE_PATTERN *family_pattern;
27
-
25
STRING *plugin_match;
26
SIMPLE_PATTERN *plugin_pattern;
27
@@ -101,7 +98,6 @@ struct rrdcalctemplate {
98
#define rrdcalctemplate_classification(rt) string2str((rt)->classification)
99
#define rrdcalctemplate_component(rt) string2str((rt)->component)
100
#define rrdcalctemplate_type(rt) string2str((rt)->type)
104
-#define rrdcalctemplate_family_match(rt) string2str((rt)->family_match)
101
#define rrdcalctemplate_plugin_match(rt) string2str((rt)->plugin_match)
102
#define rrdcalctemplate_module_match(rt) string2str((rt)->module_match)
103
#define rrdcalctemplate_charts_match(rt) string2str((rt)->charts_match)
database/sqlite/sqlite_aclk_alert.c
+35
-49
@@ -273,7 +273,7 @@ void aclk_push_alert_event(struct aclk_sync_host_config *wc)
273
sql,
274
"select aa.sequence_id, hld.unique_id, hld.alarm_id, hl.config_hash_id, hld.updated_by_id, hld.when_key, "
275
" hld.duration, hld.non_clear_duration, hld.flags, hld.exec_run_timestamp, hld.delay_up_to_timestamp, hl.name, "
276
- " hl.chart, hl.family, hl.exec, hl.recipient, ha.source, hl.units, hld.info, hld.exec_code, hld.new_status, "
276
+ " hl.chart, hl.exec, hl.recipient, ha.source, hl.units, hld.info, hld.exec_code, hld.new_status, "
277
" hld.old_status, hld.delay, hld.new_value, hld.old_value, hld.last_repeat, hl.chart_context, hld.transition_id, "
278
" hld.alarm_event_id, hl.chart_name, hld.summary "
279
" from health_log hl, aclk_alert_%s aa, alert_hash ha, health_log_detail hld "
@@ -331,64 +331,52 @@ void aclk_push_alert_event(struct aclk_sync_host_config *wc)
331
332
alarm_log.node_id = wc->node_id;
333
alarm_log.claim_id = claim_id;
334
-
334
alarm_log.chart = strdupz((char *)sqlite3_column_text(res, 12));
335
alarm_log.name = strdupz((char *)sqlite3_column_text(res, 11));
337
- alarm_log.family = sqlite3_column_bytes(res, 13) > 0 ? strdupz((char *)sqlite3_column_text(res, 13)) : NULL;
338
-
339
- //alarm_log.batch_id = wc->alerts_batch_id;
340
- //alarm_log.sequence_id = (uint64_t) sqlite3_column_int64(res, 0);
336
alarm_log.when = (time_t) sqlite3_column_int64(res, 5);
342
-
337
alarm_log.config_hash = sqlite3_uuid_unparse_strdupz(res, 3);
344
-
338
alarm_log.utc_offset = wc->host->utc_offset;
339
alarm_log.timezone = strdupz(rrdhost_abbrev_timezone(wc->host));
347
- alarm_log.exec_path = sqlite3_column_bytes(res, 14) > 0 ? strdupz((char *)sqlite3_column_text(res, 14)) :
340
+ alarm_log.exec_path = sqlite3_column_bytes(res, 13) > 0 ? strdupz((char *)sqlite3_column_text(res, 13)) :
341
strdupz((char *)string2str(wc->host->health.health_default_exec));
342
+ alarm_log.conf_source = sqlite3_column_bytes(res, 15) > 0 ? strdupz((char *)sqlite3_column_text(res, 15)) : strdupz("");
343
350
- alarm_log.conf_source = sqlite3_column_bytes(res, 16) > 0 ? strdupz((char *)sqlite3_column_text(res, 16)) : strdupz("");
351
-
352
- char *edit_command = sqlite3_column_bytes(res, 16) > 0 ?
353
- health_edit_command_from_source((char *)sqlite3_column_text(res, 16)) :
344
+ char *edit_command = sqlite3_column_bytes(res, 15) > 0 ?
345
+ health_edit_command_from_source((char *)sqlite3_column_text(res, 15)) :
346
strdupz("UNKNOWN=0=UNKNOWN");
347
alarm_log.command = strdupz(edit_command);
348
349
alarm_log.duration = (time_t) sqlite3_column_int64(res, 6);
350
alarm_log.non_clear_duration = (time_t) sqlite3_column_int64(res, 7);
359
- alarm_log.status = rrdcalc_status_to_proto_enum((RRDCALC_STATUS) sqlite3_column_int(res, 20));
360
- alarm_log.old_status = rrdcalc_status_to_proto_enum((RRDCALC_STATUS) sqlite3_column_int(res, 21));
361
- alarm_log.delay = (int) sqlite3_column_int(res, 22);
351
+ alarm_log.status = rrdcalc_status_to_proto_enum((RRDCALC_STATUS) sqlite3_column_int(res, 19));
352
+ alarm_log.old_status = rrdcalc_status_to_proto_enum((RRDCALC_STATUS) sqlite3_column_int(res, 20));
353
+ alarm_log.delay = (int) sqlite3_column_int(res, 21);
354
alarm_log.delay_up_to_timestamp = (time_t) sqlite3_column_int64(res, 10);
363
- alarm_log.last_repeat = (time_t) sqlite3_column_int64(res, 25);
364
-
355
+ alarm_log.last_repeat = (time_t) sqlite3_column_int64(res, 24);
356
alarm_log.silenced = ((sqlite3_column_int64(res, 8) & HEALTH_ENTRY_FLAG_SILENCED) ||
366
- (sqlite3_column_type(res, 15) != SQLITE_NULL &&
367
- !strncmp((char *)sqlite3_column_text(res, 15), "silent", 6))) ?
357
+ (sqlite3_column_type(res, 14) != SQLITE_NULL &&
358
+ !strncmp((char *)sqlite3_column_text(res, 14), "silent", 6))) ?
359
1 :
360
0;
370
-
361
alarm_log.value_string =
372
- sqlite3_column_type(res, 23) == SQLITE_NULL ?
362
+ sqlite3_column_type(res, 22) == SQLITE_NULL ?
363
strdupz((char *)"-") :
364
strdupz((char *)format_value_and_unit(
375
- new_value_string, 100, sqlite3_column_double(res, 23), (char *)sqlite3_column_text(res, 17), -1));
376
-
365
+ new_value_string, 100, sqlite3_column_double(res, 22), (char *)sqlite3_column_text(res, 16), -1));
366
alarm_log.old_value_string =
378
- sqlite3_column_type(res, 24) == SQLITE_NULL ?
367
+ sqlite3_column_type(res, 23) == SQLITE_NULL ?
368
strdupz((char *)"-") :
369
strdupz((char *)format_value_and_unit(
381
- old_value_string, 100, sqlite3_column_double(res, 24), (char *)sqlite3_column_text(res, 17), -1));
382
-
383
- alarm_log.value = (NETDATA_DOUBLE) sqlite3_column_double(res, 23);
384
- alarm_log.old_value = (NETDATA_DOUBLE) sqlite3_column_double(res, 24);
370
+ old_value_string, 100, sqlite3_column_double(res, 23), (char *)sqlite3_column_text(res, 16), -1));
371
+ alarm_log.value = (NETDATA_DOUBLE) sqlite3_column_double(res, 22);
372
+ alarm_log.old_value = (NETDATA_DOUBLE) sqlite3_column_double(res, 23);
373
alarm_log.updated = (sqlite3_column_int64(res, 8) & HEALTH_ENTRY_FLAG_UPDATED) ? 1 : 0;
386
- alarm_log.rendered_info = sqlite3_text_strdupz_empty(res, 18);
387
- alarm_log.chart_context = sqlite3_text_strdupz_empty(res, 26);
388
- alarm_log.transition_id = sqlite3_uuid_unparse_strdupz(res, 27);
389
- alarm_log.event_id = (time_t) sqlite3_column_int64(res, 28);
390
- alarm_log.chart_name = sqlite3_text_strdupz_empty(res, 29);
391
- alarm_log.summary = sqlite3_text_strdupz_empty(res, 30);
374
+ alarm_log.rendered_info = sqlite3_text_strdupz_empty(res, 17);
375
+ alarm_log.chart_context = sqlite3_text_strdupz_empty(res, 25);
376
+ alarm_log.transition_id = sqlite3_uuid_unparse_strdupz(res, 26);
377
+ alarm_log.event_id = (time_t) sqlite3_column_int64(res, 27);
378
+ alarm_log.chart_name = sqlite3_text_strdupz_empty(res, 28);
379
+ alarm_log.summary = sqlite3_text_strdupz_empty(res, 29);
380
381
aclk_send_alarm_log_entry(&alarm_log);
382
@@ -534,7 +522,7 @@ void aclk_send_alarm_configuration(char *config_hash)
522
523
#define SQL_SELECT_ALERT_CONFIG \
524
"SELECT alarm, template, on_key, class, type, component, os, hosts, plugin," \
537
- "module, charts, families, lookup, every, units, green, red, calc, warn, crit, to_key, exec, delay, repeat, info," \
525
+ "module, charts, lookup, every, units, green, red, calc, warn, crit, to_key, exec, delay, repeat, info," \
526
"options, host_labels, p_db_lookup_dimensions, p_db_lookup_method, p_db_lookup_options, p_db_lookup_after," \
527
"p_db_lookup_before, p_update_every, chart_labels, summary FROM alert_hash WHERE hash_id = @hash_id;"
528
@@ -596,7 +584,6 @@ int aclk_push_alert_config_event(char *node_id __maybe_unused, char *config_hash
584
alarm_config.plugin = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++);
585
alarm_config.module = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++);
586
alarm_config.charts = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++);
599
- alarm_config.families = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++);
587
alarm_config.lookup = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++);
588
alarm_config.every = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++);
589
alarm_config.units = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++);
@@ -611,7 +598,7 @@ int aclk_push_alert_config_event(char *node_id __maybe_unused, char *config_hash
598
alarm_config.repeat = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++);
599
alarm_config.info = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++);
600
alarm_config.options = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++);
614
- alarm_config.host_labels = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++); // Current param 26
601
+ alarm_config.host_labels = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++); // Current param 25
602
603
alarm_config.p_db_lookup_dimensions = NULL;
604
alarm_config.p_db_lookup_method = NULL;
@@ -619,26 +606,26 @@ int aclk_push_alert_config_event(char *node_id __maybe_unused, char *config_hash
606
alarm_config.p_db_lookup_after = 0;
607
alarm_config.p_db_lookup_before = 0;
608
622
- if (sqlite3_column_bytes(res, 30) > 0) {
609
+ if (sqlite3_column_bytes(res, 29) > 0) {
610
624
- alarm_config.p_db_lookup_dimensions = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++); // Current param 27
625
- alarm_config.p_db_lookup_method = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++); // Current param 28
626
- if (param != 29)
611
+ alarm_config.p_db_lookup_dimensions = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++); // Current param 26
612
+ alarm_config.p_db_lookup_method = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, param++); // Current param 27
613
+ if (param != 28)
614
netdata_log_error("aclk_push_alert_config_event: Unexpected param number %d", param);
615
616
BUFFER *tmp_buf = buffer_create(1024, &netdata_buffers_statistics.buffers_sqlite);
630
- buffer_data_options2string(tmp_buf, sqlite3_column_int(res, 29));
617
+ buffer_data_options2string(tmp_buf, sqlite3_column_int(res, 28));
618
alarm_config.p_db_lookup_options = strdupz((char *)buffer_tostring(tmp_buf));
619
buffer_free(tmp_buf);
620
634
- alarm_config.p_db_lookup_after = sqlite3_column_int(res, 30);
635
- alarm_config.p_db_lookup_before = sqlite3_column_int(res, 31);
621
+ alarm_config.p_db_lookup_after = sqlite3_column_int(res, 29);
622
+ alarm_config.p_db_lookup_before = sqlite3_column_int(res, 30);
623
}
624
638
- alarm_config.p_update_every = sqlite3_column_int(res, 32);
625
+ alarm_config.p_update_every = sqlite3_column_int(res, 31);
626
640
- alarm_config.chart_labels = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, 33);
641
- alarm_config.summary = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, 34);
627
+ alarm_config.chart_labels = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, 32);
628
+ alarm_config.summary = SQLITE3_COLUMN_STRDUPZ_OR_NULL(res, 33);
629
630
p_alarm_config.cfg_hash = strdupz((char *) config_hash);
631
p_alarm_config.cfg = alarm_config;
@@ -806,7 +793,6 @@ void health_alarm_entry2proto_nolock(struct alarm_log_entry *alarm_log, ALARM_EN
793
794
alarm_log->chart = strdupz(ae_chart_id(ae));
795
alarm_log->name = strdupz(ae_name(ae));
809
- alarm_log->family = strdupz(ae_family(ae));
796
797
alarm_log->batch_id = 0;
798
alarm_log->sequence_id = 0;
database/sqlite/sqlite_health.c
+57
-77
@@ -97,8 +97,8 @@ failed:
97
*/
98
#define SQL_INSERT_HEALTH_LOG \
99
"INSERT INTO health_log (host_id, alarm_id, " \
100
- "config_hash_id, name, chart, family, exec, recipient, units, chart_context, last_transition_id, chart_name) " \
101
- "VALUES (?,?,?,?,?,?,?,?,?,?,?,?) " \
100
+ "config_hash_id, name, chart, exec, recipient, units, chart_context, last_transition_id, chart_name) " \
101
+ "VALUES (?,?,?,?,?,?,?,?,?,?,?) " \
102
"ON CONFLICT (host_id, alarm_id) DO UPDATE SET last_transition_id = excluded.last_transition_id, " \
103
"chart_name = excluded.chart_name RETURNING health_log_id; "
104
@@ -154,43 +154,37 @@ static void sql_health_alarm_log_insert(RRDHOST *host, ALARM_ENTRY *ae) {
154
goto failed;
155
}
156
157
- rc = SQLITE3_BIND_STRING_OR_NULL(res, ae->family, 6);
158
- if (unlikely(rc != SQLITE_OK)) {
159
- error_report("Failed to bind family parameter for SQL_INSERT_HEALTH_LOG");
160
- goto failed;
161
- }
162
-
163
- rc = SQLITE3_BIND_STRING_OR_NULL(res, ae->exec, 7);
157
+ rc = SQLITE3_BIND_STRING_OR_NULL(res, ae->exec, 6);
158
if (unlikely(rc != SQLITE_OK)) {
159
error_report("Failed to bind exec parameter for SQL_INSERT_HEALTH_LOG");
160
goto failed;
161
}
162
169
- rc = SQLITE3_BIND_STRING_OR_NULL(res, ae->recipient, 8);
163
+ rc = SQLITE3_BIND_STRING_OR_NULL(res, ae->recipient, 7);
164
if (unlikely(rc != SQLITE_OK)) {
165
error_report("Failed to bind recipient parameter for SQL_INSERT_HEALTH_LOG");
166
goto failed;
167
}
168
175
- rc = SQLITE3_BIND_STRING_OR_NULL(res, ae->units, 9);
169
+ rc = SQLITE3_BIND_STRING_OR_NULL(res, ae->units, 8);
170
if (unlikely(rc != SQLITE_OK)) {
171
error_report("Failed to bind host_id parameter to store node instance information");
172
goto failed;
173
}
174
181
- rc = SQLITE3_BIND_STRING_OR_NULL(res, ae->chart_context, 10);
175
+ rc = SQLITE3_BIND_STRING_OR_NULL(res, ae->chart_context, 9);
176
if (unlikely(rc != SQLITE_OK)) {
177
error_report("Failed to bind chart_context parameter for SQL_INSERT_HEALTH_LOG");
178
goto failed;
179
}
180
187
- rc = sqlite3_bind_blob(res, 11, &ae->transition_id, sizeof(ae->transition_id), SQLITE_STATIC);
181
+ rc = sqlite3_bind_blob(res, 10, &ae->transition_id, sizeof(ae->transition_id), SQLITE_STATIC);
182
if (unlikely(rc != SQLITE_OK)) {
183
error_report("Failed to bind transition_id parameter for SQL_INSERT_HEALTH_LOG");
184
goto failed;
185
}
186
193
- rc = SQLITE3_BIND_STRING_OR_NULL(res, ae->chart_name, 12);
187
+ rc = SQLITE3_BIND_STRING_OR_NULL(res, ae->chart_name, 11);
188
if (unlikely(rc != SQLITE_OK)) {
189
error_report("Failed to bind chart_name parameter for SQL_INSERT_HEALTH_LOG");
190
goto failed;
@@ -745,7 +739,7 @@ void sql_check_removed_alerts_state(RRDHOST *host)
739
*/
740
#define SQL_LOAD_HEALTH_LOG "SELECT hld.unique_id, hld.alarm_id, hld.alarm_event_id, hl.config_hash_id, hld.updated_by_id, " \
741
"hld.updates_id, hld.when_key, hld.duration, hld.non_clear_duration, hld.flags, hld.exec_run_timestamp, " \
748
- "hld.delay_up_to_timestamp, hl.name, hl.chart, hl.family, hl.exec, hl.recipient, ah.source, hl.units, " \
742
+ "hld.delay_up_to_timestamp, hl.name, hl.chart, hl.exec, hl.recipient, ah.source, hl.units, " \
743
"hld.info, hld.exec_code, hld.new_status, hld.old_status, hld.delay, hld.new_value, hld.old_value, " \
744
"hld.last_repeat, ah.class, ah.component, ah.type, hl.chart_context, hld.transition_id, hld.global_id, hl.chart_name, hld.summary " \
745
"FROM health_log hl, alert_hash ah, health_log_detail hld " \
@@ -808,7 +802,7 @@ void sql_health_alarm_log_load(RRDHOST *host)
802
continue;
803
}
804
811
- //need name, chart and family
805
+ //need name and chart
806
if (sqlite3_column_type(res, 12) == SQLITE_NULL) {
807
error_report("HEALTH [%s]: Got null name field. Ignoring it.", rrdhost_hostname(host));
808
errored++;
@@ -821,14 +815,8 @@ void sql_health_alarm_log_load(RRDHOST *host)
815
continue;
816
}
817
824
- if (sqlite3_column_type(res, 14) == SQLITE_NULL) {
825
- error_report("HEALTH [%s]: Got null family field. Ignoring it.", rrdhost_hostname(host));
826
- errored++;
827
- continue;
828
- }
829
-
818
// Check if we got last_repeat field
831
- time_t last_repeat = (time_t)sqlite3_column_int64(res, 26);
819
+ time_t last_repeat = (time_t)sqlite3_column_int64(res, 25);
820
821
rc = dictionary_get(all_rrdcalcs, (char *) sqlite3_column_text(res, 13));
822
if(unlikely(rc)) {
@@ -865,37 +853,36 @@ void sql_health_alarm_log_load(RRDHOST *host)
853
854
ae->name = string_strdupz((char *) sqlite3_column_text(res, 12));
855
ae->chart = string_strdupz((char *) sqlite3_column_text(res, 13));
868
- ae->family = string_strdupz((char *) sqlite3_column_text(res, 14));
856
870
- ae->exec = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 15);
871
- ae->recipient = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 16);
872
- ae->source = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 17);
873
- ae->units = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 18);
874
- ae->info = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 19);
857
+ ae->exec = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 14);
858
+ ae->recipient = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 15);
859
+ ae->source = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 16);
860
+ ae->units = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 17);
861
+ ae->info = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 18);
862
876
- ae->exec_code = (int) sqlite3_column_int(res, 20);
877
- ae->new_status = (RRDCALC_STATUS) sqlite3_column_int(res, 21);
878
- ae->old_status = (RRDCALC_STATUS)sqlite3_column_int(res, 22);
879
- ae->delay = (int) sqlite3_column_int(res, 23);
863
+ ae->exec_code = (int) sqlite3_column_int(res, 19);
864
+ ae->new_status = (RRDCALC_STATUS) sqlite3_column_int(res, 20);
865
+ ae->old_status = (RRDCALC_STATUS)sqlite3_column_int(res, 21);
866
+ ae->delay = (int) sqlite3_column_int(res, 22);
867
881
- ae->new_value = (NETDATA_DOUBLE) sqlite3_column_double(res, 24);
882
- ae->old_value = (NETDATA_DOUBLE) sqlite3_column_double(res, 25);
868
+ ae->new_value = (NETDATA_DOUBLE) sqlite3_column_double(res, 23);
869
+ ae->old_value = (NETDATA_DOUBLE) sqlite3_column_double(res, 24);
870
871
ae->last_repeat = last_repeat;
872
886
- ae->classification = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 27);
887
- ae->component = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 28);
888
- ae->type = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 29);
889
- ae->chart_context = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 30);
873
+ ae->classification = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 26);
874
+ ae->component = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 27);
875
+ ae->type = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 28);
876
+ ae->chart_context = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 29);
877
891
- if (sqlite3_column_type(res, 31) != SQLITE_NULL)
892
- uuid_copy(ae->transition_id, *((uuid_t *)sqlite3_column_blob(res, 31)));
878
+ if (sqlite3_column_type(res, 30) != SQLITE_NULL)
879
+ uuid_copy(ae->transition_id, *((uuid_t *)sqlite3_column_blob(res, 30)));
880
894
- if (sqlite3_column_type(res, 32) != SQLITE_NULL)
895
- ae->global_id = sqlite3_column_int64(res, 32);
881
+ if (sqlite3_column_type(res, 31) != SQLITE_NULL)
882
+ ae->global_id = sqlite3_column_int64(res, 31);
883
897
- ae->chart_name = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 33);
898
- ae->summary = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 34);
884
+ ae->chart_name = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 32);
885
+ ae->summary = SQLITE3_COLUMN_STRINGDUP_OR_NULL(res, 33);
886
887
char value_string[100 + 1];
888
string_freez(ae->old_value_string);
@@ -943,11 +930,11 @@ void sql_health_alarm_log_load(RRDHOST *host)
930
* Store an alert config hash in the database
931
*/
932
#define SQL_STORE_ALERT_CONFIG_HASH "insert or replace into alert_hash (hash_id, date_updated, alarm, template, " \
946
- "on_key, class, component, type, os, hosts, lookup, every, units, calc, families, plugin, module, " \
933
+ "on_key, class, component, type, os, hosts, lookup, every, units, calc, plugin, module, " \
934
"charts, green, red, warn, crit, exec, to_key, info, delay, options, repeat, host_labels, " \
935
"p_db_lookup_dimensions, p_db_lookup_method, p_db_lookup_options, p_db_lookup_after, " \
936
"p_db_lookup_before, p_update_every, source, chart_labels, summary) values (?1,unixepoch(),?2,?3,?4,?5,?6,?7,?8,?9,?10,?11,?12," \
950
- "?13,?14,?15,?16,?17,?18,?19,?20,?21,?22,?23,?24,?25,?26,?27,?28,?29,?30,?31,?32,?33,?34,?35,?36,?37);"
937
+ "?13,?14,?15,?16,?17,?18,?19,?20,?21,?22,?23,?24,?25,?26,?27,?28,?29,?30,?31,?32,?33,?34,?35,?36);"
938
939
int sql_store_alert_config_hash(uuid_t *hash_id, struct alert_config *cfg)
940
{
@@ -1021,10 +1008,6 @@ int sql_store_alert_config_hash(uuid_t *hash_id, struct alert_config *cfg)
1008
if (unlikely(rc != SQLITE_OK))
1009
goto bind_fail;
1010
1024
- rc = SQLITE3_BIND_STRING_OR_NULL(res, cfg->families, ++param);
1025
- if (unlikely(rc != SQLITE_OK))
1026
- goto bind_fail;
1027
-
1011
rc = SQLITE3_BIND_STRING_OR_NULL(res, cfg->plugin, ++param);
1012
if (unlikely(rc != SQLITE_OK))
1013
goto bind_fail;
@@ -1182,7 +1165,6 @@ int alert_hash_and_store_config(
1165
DIGEST_ALERT_CONFIG_VAL(cfg->os);
1166
DIGEST_ALERT_CONFIG_VAL(cfg->host);
1167
DIGEST_ALERT_CONFIG_VAL(cfg->on);
1185
- DIGEST_ALERT_CONFIG_VAL(cfg->families);
1168
DIGEST_ALERT_CONFIG_VAL(cfg->plugin);
1169
DIGEST_ALERT_CONFIG_VAL(cfg->module);
1170
DIGEST_ALERT_CONFIG_VAL(cfg->charts);
@@ -1284,7 +1266,7 @@ done:
1266
#define SQL_SELECT_HEALTH_LOG \
1267
"SELECT hld.unique_id, hld.alarm_id, hld.alarm_event_id, hl.config_hash_id, hld.updated_by_id, hld.updates_id, " \
1268
"hld.when_key, hld.duration, hld.non_clear_duration, hld.flags, hld.exec_run_timestamp, " \
1287
- "hld.delay_up_to_timestamp, hl.name, hl.chart, hl.family, hl.exec, hl.recipient, ah.source, " \
1269
+ "hld.delay_up_to_timestamp, hl.name, hl.chart, hl.exec, hl.recipient, ah.source, " \
1270
"hl.units, hld.info, hld.exec_code, hld.new_status, hld.old_status, hld.delay, hld.new_value, hld.old_value, " \
1271
"hld.last_repeat, ah.class, ah.component, ah.type, hl.chart_context, hld.transition_id, hld.summary " \
1272
"FROM health_log hl, alert_hash ah, health_log_detail hld WHERE hl.config_hash_id = ah.hash_id and " \
@@ -1345,10 +1327,10 @@ void sql_health_alarm_log2json(RRDHOST *host, BUFFER *wb, uint32_t after, char *
1327
uuid_unparse_lower(*((uuid_t *) sqlite3_column_blob(res, 3)), config_hash_id);
1328
1329
char transition_id[UUID_STR_LEN] = {0};
1348
- if (sqlite3_column_type(res, 31) != SQLITE_NULL)
1349
- uuid_unparse_lower(*((uuid_t *) sqlite3_column_blob(res, 31)), transition_id);
1330
+ if (sqlite3_column_type(res, 30) != SQLITE_NULL)
1331
+ uuid_unparse_lower(*((uuid_t *) sqlite3_column_blob(res, 30)), transition_id);
1332
1351
- char *edit_command = sqlite3_column_bytes(res, 17) > 0 ? health_edit_command_from_source((char *)sqlite3_column_text(res, 17)) : strdupz("UNKNOWN=0=UNKNOWN");
1333
+ char *edit_command = sqlite3_column_bytes(res, 16) > 0 ? health_edit_command_from_source((char *)sqlite3_column_text(res, 16)) : strdupz("UNKNOWN=0=UNKNOWN");
1334
1335
if (count)
1336
buffer_sprintf(wb, ",");
@@ -1369,7 +1351,6 @@ void sql_health_alarm_log2json(RRDHOST *host, BUFFER *wb, uint32_t after, char *
1351
"\t\t\"name\": \"%s\",\n"
1352
"\t\t\"chart\": \"%s\",\n"
1353
"\t\t\"context\": \"%s\",\n"
1372
- "\t\t\"family\": \"%s\",\n"
1354
"\t\t\"class\": \"%s\",\n"
1355
"\t\t\"component\": \"%s\",\n"
1356
"\t\t\"type\": \"%s\",\n"
@@ -1394,7 +1375,7 @@ void sql_health_alarm_log2json(RRDHOST *host, BUFFER *wb, uint32_t after, char *
1375
"\t\t\"updates_id\": %u,\n"
1376
"\t\t\"value_string\": \"%s\",\n"
1377
"\t\t\"old_value_string\": \"%s\",\n"
1397
- "\t\t\"last_repeat\": \"%lu\",\n"
1378
+ "\t\t\"last_repeat\": %lu,\n"
1379
"\t\t\"silenced\": \"%s\",\n",
1380
rrdhost_hostname(host),
1381
host->utc_offset,
@@ -1406,54 +1387,53 @@ void sql_health_alarm_log2json(RRDHOST *host, BUFFER *wb, uint32_t after, char *
1387
transition_id,
1388
sqlite3_column_text(res, 12),
1389
sqlite3_column_text(res, 13),
1409
- sqlite3_column_text(res, 30),
1410
- sqlite3_column_text(res, 14),
1390
+ sqlite3_column_text(res, 29),
1391
+ sqlite3_column_text(res, 26) ? (const char *) sqlite3_column_text(res, 26) : (char *) "Unknown",
1392
sqlite3_column_text(res, 27) ? (const char *) sqlite3_column_text(res, 27) : (char *) "Unknown",
1393
sqlite3_column_text(res, 28) ? (const char *) sqlite3_column_text(res, 28) : (char *) "Unknown",
1413
- sqlite3_column_text(res, 29) ? (const char *) sqlite3_column_text(res, 29) : (char *) "Unknown",
1394
(sqlite3_column_int64(res, 9) & HEALTH_ENTRY_FLAG_PROCESSED)?"true":"false",
1395
(sqlite3_column_int64(res, 9) & HEALTH_ENTRY_FLAG_UPDATED)?"true":"false",
1396
(long unsigned int)sqlite3_column_int64(res, 10),
1397
(sqlite3_column_int64(res, 9) & HEALTH_ENTRY_FLAG_EXEC_FAILED)?"true":"false",
1418
- sqlite3_column_text(res, 15) ? (const char *) sqlite3_column_text(res, 15) : string2str(host->health.health_default_exec),
1419
- sqlite3_column_text(res, 16) ? (const char *) sqlite3_column_text(res, 16) : string2str(host->health.health_default_recipient),
1420
- sqlite3_column_int(res, 20),
1421
- sqlite3_column_text(res, 17) ? (const char *) sqlite3_column_text(res, 17) : (char *) "Unknown",
1398
+ sqlite3_column_text(res, 14) ? (const char *) sqlite3_column_text(res, 14) : string2str(host->health.health_default_exec),
1399
+ sqlite3_column_text(res, 15) ? (const char *) sqlite3_column_text(res, 15) : string2str(host->health.health_default_recipient),
1400
+ sqlite3_column_int(res, 19),
1401
+ sqlite3_column_text(res, 16) ? (const char *) sqlite3_column_text(res, 16) : (char *) "Unknown",
1402
edit_command,
1423
- sqlite3_column_text(res, 18),
1403
+ sqlite3_column_text(res, 17),
1404
(long unsigned int)sqlite3_column_int64(res, 6),
1405
(long unsigned int)sqlite3_column_int64(res, 7),
1406
(long unsigned int)sqlite3_column_int64(res, 8),
1407
+ rrdcalc_status2string(sqlite3_column_int(res, 20)),
1408
rrdcalc_status2string(sqlite3_column_int(res, 21)),
1428
- rrdcalc_status2string(sqlite3_column_int(res, 22)),
1429
- sqlite3_column_int(res, 23),
1409
+ sqlite3_column_int(res, 22),
1410
(long unsigned int)sqlite3_column_int64(res, 11),
1411
(unsigned int)sqlite3_column_int64(res, 4),
1412
(unsigned int)sqlite3_column_int64(res, 5),
1433
- sqlite3_column_type(res, 24) == SQLITE_NULL ? "-" : format_value_and_unit(new_value_string, 100, sqlite3_column_double(res, 24), (char *) sqlite3_column_text(res, 18), -1),
1434
- sqlite3_column_type(res, 25) == SQLITE_NULL ? "-" : format_value_and_unit(old_value_string, 100, sqlite3_column_double(res, 25), (char *) sqlite3_column_text(res, 18), -1),
1435
- (long unsigned int)sqlite3_column_int64(res, 26),
1413
+ sqlite3_column_type(res, 23) == SQLITE_NULL ? "-" : format_value_and_unit(new_value_string, 100, sqlite3_column_double(res, 23), (char *) sqlite3_column_text(res, 17), -1),
1414
+ sqlite3_column_type(res, 24) == SQLITE_NULL ? "-" : format_value_and_unit(old_value_string, 100, sqlite3_column_double(res, 24), (char *) sqlite3_column_text(res, 17), -1),
1415
+ (long unsigned int)sqlite3_column_int64(res, 25),
1416
(sqlite3_column_int64(res, 9) & HEALTH_ENTRY_FLAG_SILENCED)?"true":"false");
1417
1438
- health_string2json(wb, "\t\t", "summary", (char *) sqlite3_column_text(res, 32), ",\n");
1439
- health_string2json(wb, "\t\t", "info", (char *) sqlite3_column_text(res, 19), ",\n");
1418
+ health_string2json(wb, "\t\t", "summary", (char *) sqlite3_column_text(res, 31), ",\n");
1419
+ health_string2json(wb, "\t\t", "info", (char *) sqlite3_column_text(res, 18), ",\n");
1420
1421
if(unlikely(sqlite3_column_int64(res, 9) & HEALTH_ENTRY_FLAG_NO_CLEAR_NOTIFICATION)) {
1422
buffer_strcat(wb, "\t\t\"no_clear_notification\": true,\n");
1423
}
1424
1425
buffer_strcat(wb, "\t\t\"value\":");
1446
- if (sqlite3_column_type(res, 24) == SQLITE_NULL)
1426
+ if (sqlite3_column_type(res, 23) == SQLITE_NULL)
1427
buffer_strcat(wb, "null");
1428
else
1449
- buffer_print_netdata_double(wb, sqlite3_column_double(res, 24));
1429
+ buffer_print_netdata_double(wb, sqlite3_column_double(res, 23));
1430
buffer_strcat(wb, ",\n");
1431
1432
buffer_strcat(wb, "\t\t\"old_value\":");
1453
- if (sqlite3_column_type(res, 25) == SQLITE_NULL)
1433
+ if (sqlite3_column_type(res, 24) == SQLITE_NULL)
1434
buffer_strcat(wb, "null");
1435
else
1456
- buffer_print_netdata_double(wb, sqlite3_column_double(res, 25));
1436
+ buffer_print_netdata_double(wb, sqlite3_column_double(res, 24));
1437
buffer_strcat(wb, "\n");
1438
1439
buffer_strcat(wb, "\t}");
health/health.c
+5
-16
@@ -61,7 +61,6 @@ static bool prepare_command(BUFFER *wb,
61
uint32_t when,
62
const char *alert_name,
63
const char *alert_chart_name,
64
- const char *alert_family,
64
const char *new_status,
65
const char *old_status,
66
NETDATA_DOUBLE new_value,
@@ -118,10 +117,6 @@ static bool prepare_command(BUFFER *wb,
117
return false;
118
buffer_sprintf(wb, " '%s'", buf);
119
121
- if (!sanitize_command_argument_string(buf, alert_family, n))
122
- return false;
123
- buffer_sprintf(wb, " '%s'", buf);
124
-
120
if (!sanitize_command_argument_string(buf, new_status, n))
121
return false;
122
buffer_sprintf(wb, " '%s'", buf);
@@ -565,7 +560,6 @@ static inline void health_alarm_execute(RRDHOST *host, ALARM_ENTRY *ae) {
560
(unsigned long)ae->when,
561
ae_name(ae),
562
ae->chart?ae_chart_id(ae):"NOCHART",
568
- ae->family?ae_family(ae):"NOFAMILY",
563
rrdcalc_status2string(ae->new_status),
564
rrdcalc_status2string(ae->old_status),
565
ae->new_value,
@@ -879,28 +873,26 @@ static void health_sleep(time_t next_run, unsigned int loop __maybe_unused) {
873
874
static SILENCE_TYPE check_silenced(RRDCALC *rc, const char *host, SILENCERS *silencers) {
875
SILENCER *s;
882
- netdata_log_debug(D_HEALTH, "Checking if alarm was silenced via the command API. Alarm info name:%s context:%s chart:%s host:%s family:%s",
883
- rrdcalc_name(rc), (rc->rrdset)?rrdset_context(rc->rrdset):"", rrdcalc_chart_name(rc), host, (rc->rrdset)?rrdset_family(rc->rrdset):"");
876
+ netdata_log_debug(D_HEALTH, "Checking if alarm was silenced via the command API. Alarm info name:%s context:%s chart:%s host:%s",
877
+ rrdcalc_name(rc), (rc->rrdset)?rrdset_context(rc->rrdset):"", rrdcalc_chart_name(rc), host);
878
879
for (s = silencers->silencers; s!=NULL; s=s->next){
880
if (
881
(!s->alarms_pattern || (rc->name && s->alarms_pattern && simple_pattern_matches_string(s->alarms_pattern, rc->name))) &&
882
(!s->contexts_pattern || (rc->rrdset && rc->rrdset->context && s->contexts_pattern && simple_pattern_matches_string(s->contexts_pattern, rc->rrdset->context))) &&
883
(!s->hosts_pattern || (host && s->hosts_pattern && simple_pattern_matches(s->hosts_pattern, host))) &&
890
- (!s->charts_pattern || (rc->chart && s->charts_pattern && simple_pattern_matches_string(s->charts_pattern, rc->chart))) &&
891
- (!s->families_pattern || (rc->rrdset && rc->rrdset->family && s->families_pattern && simple_pattern_matches_string(s->families_pattern, rc->rrdset->family)))
884
+ (!s->charts_pattern || (rc->chart && s->charts_pattern && simple_pattern_matches_string(s->charts_pattern, rc->chart)))
885
) {
893
- netdata_log_debug(D_HEALTH, "Alarm matches command API silence entry %s:%s:%s:%s:%s", s->alarms,s->charts, s->contexts, s->hosts, s->families);
886
+ netdata_log_debug(D_HEALTH, "Alarm matches command API silence entry %s:%s:%s:%s", s->alarms,s->charts, s->contexts, s->hosts);
887
if (unlikely(silencers->stype == STYPE_NONE)) {
888
netdata_log_debug(D_HEALTH, "Alarm %s matched a silence entry, but no SILENCE or DISABLE command was issued via the command API. The match has no effect.", rrdcalc_name(rc));
889
} else {
897
- netdata_log_debug(D_HEALTH, "Alarm %s via the command API - name:%s context:%s chart:%s host:%s family:%s"
890
+ netdata_log_debug(D_HEALTH, "Alarm %s via the command API - name:%s context:%s chart:%s host:%s"
891
, (silencers->stype == STYPE_DISABLE_ALARMS)?"Disabled":"Silenced"
892
, rrdcalc_name(rc)
893
, (rc->rrdset)?rrdset_context(rc->rrdset):""
894
, rrdcalc_chart_name(rc)
895
, host
903
- , (rc->rrdset)?rrdset_family(rc->rrdset):""
896
);
897
}
898
return silencers->stype;
@@ -1151,7 +1143,6 @@ void *health_main(void *ptr) {
1143
rc->rrdset->id,
1144
rc->rrdset->context,
1145
rc->rrdset->name,
1154
- rc->rrdset->family,
1146
rc->classification,
1147
rc->component,
1148
rc->type,
@@ -1419,7 +1410,6 @@ void *health_main(void *ptr) {
1410
rc->rrdset->id,
1411
rc->rrdset->context,
1412
rc->rrdset->name,
1422
- rc->rrdset->family,
1413
rc->classification,
1414
rc->component,
1415
rc->type,
@@ -1507,7 +1497,6 @@ void *health_main(void *ptr) {
1497
rc->rrdset->id,
1498
rc->rrdset->context,
1499
rc->rrdset->name,
1510
- rc->rrdset->family,
1500
rc->classification,
1501
rc->component,
1502
rc->type,
health/health.h
-1
@@ -71,7 +71,6 @@ ALARM_ENTRY* health_create_alarm_entry(
71
STRING *chart,
72
STRING *chart_context,
73
STRING *chart_id,
74
- STRING *family,
74
STRING *classification,
75
STRING *component,
76
STRING *type,
health/health_config.c
-13
@@ -9,7 +9,6 @@
9
#define HEALTH_ON_KEY "on"
10
#define HEALTH_HOST_KEY "hosts"
11
#define HEALTH_OS_KEY "os"
12
-#define HEALTH_FAMILIES_KEY "families"
12
#define HEALTH_PLUGIN_KEY "plugin"
13
#define HEALTH_MODULE_KEY "module"
14
#define HEALTH_CHARTS_KEY "charts"
@@ -475,7 +474,6 @@ static inline void alert_config_free(struct alert_config *cfg)
474
string_freez(cfg->os);
475
string_freez(cfg->host);
476
string_freez(cfg->on);
478
- string_freez(cfg->families);
477
string_freez(cfg->plugin);
478
string_freez(cfg->module);
479
string_freez(cfg->charts);
@@ -517,7 +515,6 @@ static int health_readfile(const char *filename, void *data) {
515
hash_os = 0,
516
hash_on = 0,
517
hash_host = 0,
520
- hash_families = 0,
518
hash_plugin = 0,
519
hash_module = 0,
520
hash_charts = 0,
@@ -550,7 +547,6 @@ static int health_readfile(const char *filename, void *data) {
547
hash_on = simple_uhash(HEALTH_ON_KEY);
548
hash_os = simple_uhash(HEALTH_OS_KEY);
549
hash_host = simple_uhash(HEALTH_HOST_KEY);
553
- hash_families = simple_uhash(HEALTH_FAMILIES_KEY);
550
hash_plugin = simple_uhash(HEALTH_PLUGIN_KEY);
551
hash_module = simple_uhash(HEALTH_MODULE_KEY);
552
hash_charts = simple_uhash(HEALTH_CHARTS_KEY);
@@ -1088,15 +1084,6 @@ static int health_readfile(const char *filename, void *data) {
1084
}
1085
rt->type = string_strdupz(value);
1086
}
1091
- else if(hash == hash_families && !strcasecmp(key, HEALTH_FAMILIES_KEY)) {
1092
- alert_cfg->families = string_strdupz(value);
1093
- string_freez(rt->family_match);
1094
- simple_pattern_free(rt->family_pattern);
1095
-
1096
- rt->family_match = string_strdupz(value);
1097
- rt->family_pattern = simple_pattern_create(rrdcalctemplate_family_match(rt), NULL, SIMPLE_PATTERN_EXACT,
1098
- true);
1099
- }
1087
else if(hash == hash_plugin && !strcasecmp(key, HEALTH_PLUGIN_KEY)) {
1088
alert_cfg->plugin = string_strdupz(value);
1089
string_freez(rt->plugin_match);
health/health_json.c
-2
@@ -49,7 +49,6 @@ static inline void health_rrdcalc2json_nolock(RRDHOST *host, BUFFER *wb, RRDCALC
49
"\t\t\t\"config_hash_id\": \"%s\",\n"
50
"\t\t\t\"name\": \"%s\",\n"
51
"\t\t\t\"chart\": \"%s\",\n"
52
- "\t\t\t\"family\": \"%s\",\n"
52
"\t\t\t\"class\": \"%s\",\n"
53
"\t\t\t\"component\": \"%s\",\n"
54
"\t\t\t\"type\": \"%s\",\n"
@@ -83,7 +82,6 @@ static inline void health_rrdcalc2json_nolock(RRDHOST *host, BUFFER *wb, RRDCALC
82
, hash_id
83
, rrdcalc_name(rc)
84
, rrdcalc_chart_name(rc)
86
- , (rc->rrdset)?rrdset_family(rc->rrdset):""
85
, rc->classification?rrdcalc_classification(rc):"Unknown"
86
, rc->component?rrdcalc_component(rc):"Unknown"
87
, rc->type?rrdcalc_type(rc):"Unknown"
health/health_log.c
-3
@@ -21,7 +21,6 @@ inline ALARM_ENTRY* health_create_alarm_entry(
21
STRING *chart,
22
STRING *chart_context,
23
STRING *chart_name,
24
- STRING *family,
24
STRING *class,
25
STRING *component,
26
STRING *type,
@@ -52,7 +51,6 @@ inline ALARM_ENTRY* health_create_alarm_entry(
51
uuid_generate_random(ae->transition_id);
52
ae->global_id = now_realtime_usec();
53
55
- ae->family = string_dup(family);
54
ae->classification = string_dup(class);
55
ae->component = string_dup(component);
56
ae->type = string_dup(type);
@@ -134,7 +132,6 @@ inline void health_alarm_log_free_one_nochecks_nounlink(ALARM_ENTRY *ae) {
132
string_freez(ae->name);
133
string_freez(ae->chart);
134
string_freez(ae->chart_context);
137
- string_freez(ae->family);
135
string_freez(ae->classification);
136
string_freez(ae->component);
137
string_freez(ae->type);
health/notifications/alarm-notify.sh.in
+40
-69
@@ -58,7 +58,7 @@ if { [ "${1}" = "test" ] || [ "${2}" = "test" ]; } && [ "${#}" -le 2 ]; then
58
echo >&2
59
echo >&2 "# SENDING TEST ${x} ALARM TO ROLE: ${recipient}"
60
61
- "${0}" "${recipient}" "$(hostname)" 1 1 "${id}" "$(date +%s)" "test_alarm" "test.chart" "test.family" "${x}" "${last}" 100 90 "${0}" 1 $((0 + id)) "units" "this is a test alarm to verify notifications work" "new value" "old value" "evaluated expression" "expression variable values" 0 0
61
+ "${0}" "${recipient}" "$(hostname)" 1 1 "${id}" "$(date +%s)" "test_alarm" "test.chart" "${x}" "${last}" 100 90 "${0}" 1 $((0 + id)) "units" "this is a test alarm to verify notifications work" "new value" "old value" "evaluated expression" "expression variable values" 0 0 "" "" "Test" "command to edit the alarm=0=$(hostname)" "" "" "a test alarm"
62
#shellcheck disable=SC2181
63
if [ $? -ne 0 ]; then
64
echo >&2 "# FAILED"
@@ -239,31 +239,30 @@ else
239
when="${6}" # the timestamp this event occurred
240
name="${7}" # the name of the alarm, as given in netdata health.d entries
241
chart="${8}" # the name of the chart (type.id)
242
- family="${9}" # the family of the chart
243
- status="${10}" # the current status : REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL
244
- old_status="${11}" # the previous status: REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL
245
- value="${12}" # the current value of the alarm
246
- old_value="${13}" # the previous value of the alarm
247
- src="${14}" # the line number and file the alarm has been configured
248
- duration="${15}" # the duration in seconds of the previous alarm state
249
- non_clear_duration="${16}" # the total duration in seconds this is/was non-clear
250
- units="${17}" # the units of the value
251
- info="${18}" # a short description of the alarm
252
- value_string="${19}" # friendly value (with units)
242
+ status="${9}" # the current status : REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL
243
+ old_status="${10}" # the previous status: REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL
244
+ value="${11}" # the current value of the alarm
245
+ old_value="${12}" # the previous value of the alarm
246
+ src="${13}" # the line number and file the alarm has been configured
247
+ duration="${14}" # the duration in seconds of the previous alarm state
248
+ non_clear_duration="${15}" # the total duration in seconds this is/was non-clear
249
+ units="${16}" # the units of the value
250
+ info="${17}" # a short description of the alarm
251
+ value_string="${18}" # friendly value (with units)
252
# shellcheck disable=SC2034
253
# variable is unused, but https://github.com/netdata/netdata/pull/5164#discussion_r255572947
255
- old_value_string="${20}" # friendly old value (with units), previously named "old_value_string"
256
- calc_expression="${21}" # contains the expression that was evaluated to trigger the alarm
257
- calc_param_values="${22}" # the values of the parameters in the expression, at the time of the evaluation
258
- total_warnings="${23}" # Total number of alarms in WARNING state
259
- total_critical="${24}" # Total number of alarms in CRITICAL state
260
- total_warn_alarms="${25}" # List of alarms in warning state
261
- total_crit_alarms="${26}" # List of alarms in critical state
262
- classification="${27}" # The class field from .conf files
263
- edit_command_line="${28}" # The command to edit the alarm, with the line number
264
- child_machine_guid="${29}" # the machine_guid of the child
265
- transition_id="${30}" # the transition_id of the alert
266
- summary="${31}" # the summary text field of the alert
254
+ old_value_string="${19}" # friendly old value (with units), previously named "old_value_string"
255
+ calc_expression="${20}" # contains the expression that was evaluated to trigger the alarm
256
+ calc_param_values="${21}" # the values of the parameters in the expression, at the time of the evaluation
257
+ total_warnings="${22}" # Total number of alarms in WARNING state
258
+ total_critical="${23}" # Total number of alarms in CRITICAL state
259
+ total_warn_alarms="${24}" # List of alarms in warning state
260
+ total_crit_alarms="${25}" # List of alarms in critical state
261
+ classification="${26}" # The class field from .conf files
262
+ edit_command_line="${27}" # The command to edit the alarm, with the line number
263
+ child_machine_guid="${28}" # the machine_guid of the child
264
+ transition_id="${29}" # the transition_id of the alert
265
+ summary="${30}" # the summary text field of the alert
266
fi
267
268
# -----------------------------------------------------------------------------
@@ -1133,7 +1132,7 @@ send_kafka() {
1132
local httpcode sent=0
1133
if [ "${SEND_KAFKA}" = "YES" ]; then
1134
httpcode=$(docurl -X POST \
1136
- --data "{host_ip:\"${KAFKA_SENDER_IP}\",when:${when},name:\"${name}\",chart:\"${chart}\",family:\"${family}\",status:\"${status}\",old_status:\"${old_status}\",value:${value},old_value:${old_value},duration:${duration},non_clear_duration:${non_clear_duration},units:\"${units}\",info:\"${info}\"}" \
1135
+ --data "{host_ip:\"${KAFKA_SENDER_IP}\",when:${when},name:\"${name}\",chart:\"${chart}\",status:\"${status}\",old_status:\"${old_status}\",value:${value},old_value:${old_value},duration:${duration},non_clear_duration:${non_clear_duration},units:\"${units}\",info:\"${info}\"}" \
1136
"${KAFKA_URL}")
1137
1138
if [ "${httpcode}" = "204" ]; then
@@ -1168,7 +1167,7 @@ send_pd() {
1167
current_time=$(date -r ${when} +'%Y-%m-%dT%H:%M:%S.000')
1168
fi
1169
for PD_SERVICE_KEY in ${recipients}; do
1171
- d="${status} ${name} = ${value_string} - ${host}, ${family}"
1170
+ d="${status} ${name} = ${value_string} - ${host}"
1171
if [ ${USE_PD_VERSION} = "2" ]; then
1172
payload="$(
1173
cat <<EOF
@@ -1178,7 +1177,6 @@ send_pd() {
1177
"source" : "${args_host}",
1178
"severity" : "${severity}",
1179
"timestamp" : "${current_time}",
1181
- "group" : "${family}",
1180
"class" : "${chart}",
1181
"custom_details": {
1182
"value_w_units": "${value_string}",
@@ -1188,7 +1186,6 @@ send_pd() {
1186
"alarm_id" : "${alarm_id}",
1187
"name" : "${name}",
1188
"chart" : "${chart}",
1191
- "family" : "${family}",
1189
"status" : "${status}",
1190
"old_status" : "${old_status}",
1191
"value" : "${value}",
@@ -1223,7 +1220,6 @@ EOF
1220
"alarm_id" : "${alarm_id}",
1221
"name" : "${name}",
1222
"chart" : "${chart}",
1226
- "family" : "${family}",
1223
"status" : "${status}",
1224
"old_status" : "${old_status}",
1225
"value" : "${value}",
@@ -1471,7 +1467,7 @@ send_msteams() {
1467
"@type": "MessageCard",
1468
"themeColor": "${color}",
1469
"title": "$icon Alert ${status} from netdata for ${host}",
1474
- "text": "${host} ${status_message}, ${chart} (_${family}_), *${alarm}*",
1470
+ "text": "${host} ${status_message}, ${chart}, *${alarm}*",
1471
"potentialAction": [
1472
{
1473
"@type": "OpenUri",
@@ -1536,10 +1532,10 @@ send_slack() {
1532
$ch
1533
"username": "netdata on ${host}",
1534
"icon_url": "${images_base_url}/images/banner-icon-144x144.png",
1539
- "text": "${host} ${status_message}, \`${chart}\` (_${family}_), *${alarm}*",
1535
+ "text": "${host} ${status_message}, \`${chart}\`, *${alarm}*",
1536
"attachments": [
1537
{
1542
- "fallback": "${alarm} - ${chart} (${family}) - ${info}",
1538
+ "fallback": "${alarm} - ${chart} - ${info}",
1539
"color": "${color}",
1540
"title": "${alarm}",
1541
"title_link": "${goto_url}",
@@ -1549,11 +1545,6 @@ send_slack() {
1545
"title": "${chart}",
1546
"value": "chart",
1547
"short": true
1552
- },
1553
- {
1554
- "title": "${family}",
1555
- "value": "family",
1556
- "short": true
1548
}
1549
],
1550
"thumb_url": "${image}",
@@ -1601,7 +1592,7 @@ send_rocketchat() {
1592
"channel": "#${channel}",
1593
"alias": "netdata on ${host}",
1594
"avatar": "${images_base_url}/images/banner-icon-144x144.png",
1604
- "text": "${host} ${status_message}, \`${chart}\` (_${family}_), *${alarm}*",
1595
+ "text": "${host} ${status_message}, \`${chart}\`, *${alarm}*",
1596
"attachments": [
1597
{
1598
"color": "${color}",
@@ -1613,11 +1604,6 @@ send_rocketchat() {
1604
"title": "${chart}",
1605
"short": true,
1606
"value": "chart"
1616
- },
1617
- {
1618
- "title": "${family}",
1619
- "short": true,
1620
- "value": "family"
1607
}
1608
],
1609
"thumb_url": "${image}",
@@ -1661,7 +1647,7 @@ send_alerta() {
1647
resource=$chart
1648
event=$name
1649
else
1664
- resource="${host}:${family}"
1650
+ resource="${host}"
1651
event="${chart}.${name}"
1652
fi
1653
@@ -1682,7 +1668,6 @@ send_alerta() {
1668
"roles": "${roles}",
1669
"name": "${name}",
1670
"chart": "${chart}",
1685
- "family": "${family}",
1671
"source": "${src}",
1672
"moreInfo": "<a href=\"${goto_url}\">View Netdata</a>"
1673
},
@@ -1739,7 +1724,7 @@ send_flock() {
1724
\"timestamp\": \"${when}\",
1725
\"attachments\": [
1726
{
1742
- \"description\": \"${chart} (${family}) - ${info}\",
1727
+ \"description\": \"${chart} - ${info}\",
1728
\"color\": \"${color}\",
1729
\"title\": \"${alarm}\",
1730
\"url\": \"${goto_url}\",
@@ -1791,7 +1776,7 @@ send_discord() {
1776
{
1777
"channel": "#${channel}",
1778
"username": "${username}",
1794
- "text": "${host} ${status_message}, \`${chart}\` (_${family}_), *${alarm}*",
1779
+ "text": "${host} ${status_message}, \`${chart}\`, *${alarm}*",
1780
"icon_url": "${images_base_url}/images/banner-icon-144x144.png",
1781
"attachments": [
1782
{
@@ -1802,7 +1787,6 @@ send_discord() {
1787
"fields": [
1788
{
1789
"title": "${chart}",
1805
- "value": "${family}"
1790
}
1791
],
1792
"thumb_url": "${image}",
@@ -1835,7 +1819,7 @@ EOF
1819
send_fleep() {
1820
local httpcode sent=0 webhooks="${1}" data message
1821
if [ "${SEND_FLEEP}" = "YES" ]; then
1838
- message="${host} ${status_message}, \`${chart}\` (${family}), *${alarm}*\\n${info}"
1822
+ message="${host} ${status_message}, \`${chart}\`, *${alarm}*\\n${info}"
1823
1824
for hook in ${webhooks}; do
1825
data="{ "
@@ -1865,7 +1849,7 @@ send_fleep() {
1849
send_prowl() {
1850
local httpcode sent=0 data message keys prio=0 alarm_url event
1851
if [ "${SEND_PROWL}" = "YES" ]; then
1868
- message="$(urlencode "${host} ${status_message}, \`${chart}\` (${family}), *${alarm}*\\n${info}")"
1852
+ message="$(urlencode "${host} ${status_message}, \`${chart}\`, *${alarm}*\\n${info}")"
1853
message="description=${message}"
1854
keys="$(urlencode "$(echo "${1}" | tr ' ' ,)")"
1855
keys="apikey=${keys}"
@@ -1995,8 +1979,8 @@ send_matrix() {
1979
{
1980
"msgtype": "m.notice",
1981
"format": "org.matrix.custom.html",
1998
- "formatted_body": "${emoji} ${host} ${status_message} - <b>${name//_/ }</b><br>${chart} (${family})<br><a href=\"${goto_url}\">${alarm}</a><br><i>${info}</i>",
1999
- "body": "${emoji} ${host} ${status_message} - ${name//_/ } ${chart} (${family}) ${goto_url} ${alarm} ${info}"
1982
+ "formatted_body": "${emoji} ${host} ${status_message} - <b>${name//_/ }</b><br>${chart}<br><a href=\"${goto_url}\">${alarm}</a><br><i>${info}</i>",
1983
+ "body": "${emoji} ${host} ${status_message} - ${name//_/ } ${chart} ${goto_url} ${alarm} ${info}"
1984
}
1985
EOF
1986
)"
@@ -2094,7 +2078,7 @@ send_sms() {
2078
local recipients="${1}" errcode errmessage sent=0
2079
2080
# Human readable SMS
2097
- local msg="${host} ${status_message}: ${chart} (${family}), ${alarm}"
2081
+ local msg="${host} ${status_message}: ${chart}, ${alarm}"
2082
2083
# limit it to 160 characters
2084
msg="${msg:0:160}"
@@ -2118,7 +2102,6 @@ send_sms() {
2102
return 1
2103
}
2104
2121
-
2105
# -----------------------------------------------------------------------------
2106
# Dynatrace sender
2107
@@ -2201,7 +2184,6 @@ send_opsgenie() {
2184
"chart" : "${chart}",
2185
"when": ${when},
2186
"name" : "${name}",
2204
- "family" : "${family}",
2187
"priority" : "${priority}",
2188
"status" : "${status}",
2189
"old_status" : "${old_status}",
@@ -2336,14 +2318,12 @@ urlencode "${args_host}" >/dev/null
2318
url_host="${REPLY}"
2319
urlencode "${chart}" >/dev/null
2320
url_chart="${REPLY}"
2339
-urlencode "${family}" >/dev/null
2340
-url_family="${REPLY}"
2321
urlencode "${name}" >/dev/null
2322
url_name="${REPLY}"
2323
urlencode "${value_string}" >/dev/null
2324
url_value_string="${REPLY}"
2325
2346
-redirect_params="host=${url_host}&chart=${url_chart}&family=${url_family}&alarm=${url_name}&alarm_unique_id=${unique_id}&alarm_id=${alarm_id}&alarm_event_id=${event_id}&alarm_when=${when}&alarm_status=${status}&alarm_chart=${chart}&alarm_value=${url_value_string}"
2326
+redirect_params="host=${url_host}&chart=${url_chart}&alarm=${url_name}&alarm_unique_id=${unique_id}&alarm_id=${alarm_id}&alarm_event_id=${event_id}&alarm_when=${when}&alarm_status=${status}&alarm_chart=${chart}&alarm_value=${url_value_string}"
2327
2328
if [ -z "${NETDATA_REGISTRY_UNIQUE_ID}" ]; then
2329
if [ -f "@registrydir_POST@/netdata.public.unique.id" ]; then
@@ -2522,7 +2502,6 @@ SENT_DISCORD=$?
2502
send_pushover "${PUSHOVER_APP_TOKEN}" "${to_pushover}" "${when}" "${goto_url}" "${status}" "${host} ${status_message} - ${name//_/ } - ${chart}" "
2503
<font color=\"${color}\"><b>${alarm}</b></font>${info_html}<br/>
2504
<small><b>${chart}</b><br/>Chart<br/> </small>
2525
-<small><b>${family}</b><br/>Family<br/> </small>
2505
<small><b>${severity}</b><br/>Severity<br/> </small>
2506
<small><b>${date}${raised_for_html}</b><br/>Time<br/> </small>
2507
<a href=\"${goto_url}\">View Netdata</a><br/>
@@ -2537,7 +2516,6 @@ SENT_PUSHOVER=$?
2516
send_pushbullet "${PUSHBULLET_ACCESS_TOKEN}" "${PUSHBULLET_SOURCE_DEVICE}" "${to_pushbullet}" "${goto_url}" "${host} ${status_message} - ${name//_/ } - ${chart}" "${alarm}\\n
2517
Severity: ${severity}\\n
2518
Chart: ${chart}\\n
2540
-Family: ${family}\\n
2519
${date}\\n
2520
The source of this alarm is line ${src}"
2521
@@ -2549,7 +2527,6 @@ SENT_PUSHBULLET=$?
2527
send_twilio "${TWILIO_ACCOUNT_SID}" "${TWILIO_ACCOUNT_TOKEN}" "${TWILIO_NUMBER}" "${to_twilio}" "${host} ${status_message} - ${name//_/ } - ${chart}" "${alarm}
2528
Severity: ${severity}
2529
Chart: ${chart}
2552
-Family: ${family}
2530
${info}"
2531
2532
SENT_TWILIO=$?
@@ -2560,7 +2537,6 @@ SENT_TWILIO=$?
2537
send_messagebird "${MESSAGEBIRD_ACCESS_KEY}" "${MESSAGEBIRD_NUMBER}" "${to_messagebird}" "${host} ${status_message} - ${name//_/ } - ${chart}" "${alarm}
2538
Severity: ${severity}
2539
Chart: ${chart}
2563
-Family: ${family}
2540
${info}"
2541
2542
SENT_MESSAGEBIRD=$?
@@ -2571,7 +2547,6 @@ SENT_MESSAGEBIRD=$?
2547
send_kavenegar "${KAVENEGAR_API_KEY}" "${KAVENEGAR_SENDER}" "${to_kavenegar}" "${host} ${status_message} - ${name//_/ } - ${chart}" "${alarm}
2548
Severity: ${severity}
2549
Chart: ${chart}
2574
-Family: ${family}
2550
${info}"
2551
2552
SENT_KAVENEGAR=$?
@@ -2581,7 +2556,7 @@ SENT_KAVENEGAR=$?
2556
2557
# https://core.telegram.org/bots/api#formatting-options
2558
send_telegram "${TELEGRAM_BOT_TOKEN}" "${to_telegram}" "${host} ${status_message} - <b>${name//_/ }</b>
2584
-${chart} (${family})
2559
+${chart}
2560
<a href=\"${goto_url}\">${alarm}</a>
2561
<i>${info}</i>"
2562
@@ -2617,7 +2592,6 @@ SENT_PROWL=$?
2592
send_irc "${IRC_NICKNAME}" "${IRC_REALNAME}" "${to_irc}" "${IRC_NETWORK}" "${IRC_PORT}" "${host}" "${host} ${status_message} - ${name//_/ } - ${chart} ----- ${alarm}
2593
Severity: ${severity}
2594
Chart: ${chart}
2620
-Family: ${family}
2595
${info}"
2596
2597
SENT_IRC=$?
@@ -2652,7 +2626,7 @@ SENT_CUSTOM=$?
2626
send_hipchat "${HIPCHAT_AUTH_TOKEN}" "${to_hipchat}" " \
2627
${host} ${status_message}<br/> \
2628
<b>${alarm}</b> ${info_html}<br/> \
2655
-<b>${chart}</b> (family <b>${family}</b>)<br/> \
2629
+<b>${chart}</b><br/> \
2630
<b>${date}${raised_for_html}</b><br/> \
2631
<a href=\\\"${goto_url}\\\">View netdata dashboard</a> \
2632
(source of alarm ${src}) \
@@ -2695,7 +2669,6 @@ ${alarm} ${info}
2669
${raised_for}
2670
2671
Chart : ${chart}
2698
-Family : ${family}
2672
Severity: ${severity}
2673
URL : ${goto_url}
2674
Source : ${src}
@@ -2719,7 +2692,6 @@ ${email_thread_headers}
2692
X-Netdata-Severity: ${status,,}
2693
X-Netdata-Alert-Name: $name
2694
X-Netdata-Chart: $chart
2722
-X-Netdata-Family: $family
2695
X-Netdata-Classification: $classification
2696
X-Netdata-Host: $host
2697
X-Netdata-Role: $roles
@@ -3473,7 +3445,6 @@ ${email_thread_headers}
3445
X-Netdata-Severity: ${status,,}
3446
X-Netdata-Alert-Name: $name
3447
X-Netdata-Chart: $chart
3476
-X-Netdata-Family: $family
3448
X-Netdata-Classification: $classification
3449
X-Netdata-Host: $host
3450
X-Netdata-Role: $roles
health/notifications/awssns/metadata.yaml
-2
@@ -75,8 +75,6 @@
75
| `${url_name}` | Same as ${name} but URL encoded |
76
| `${chart}` | The name of the chart (type.id) |
77
| `${url_chart}` | Same as ${chart} but URL encoded |
78
- | `${family}` | The family of the chart |
79
- | `${url_family}` | Same as ${family} but URL encoded |
78
| `${status}` | The current status : REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL |
79
| `${old_status}` | The previous status: REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL |
80
| `${value}` | The current value of the alarm |
health/notifications/custom/metadata.yaml
-2
@@ -99,8 +99,6 @@
99
| `${url_name}` | Same as ${name} but URL encoded |
100
| `${chart}` | The name of the chart (type.id) |
101
| `${url_chart}` | Same as ${chart} but URL encoded |
102
- | `${family}` | The family of the chart |
103
- | `${url_family}` | Same as ${family} but URL encoded |
102
| `${status}` | The current status : REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL |
103
| `${old_status}` | The previous status: REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL |
104
| `${value}` | The current value of the alarm |
health/notifications/health_alarm_notify.conf
-2
@@ -867,8 +867,6 @@ custom_sender() {
867
# ${url_name} same as ${name} but URL encoded
868
# ${chart} the name of the chart (type.id)
869
# ${url_chart} same as ${chart} but URL encoded
870
- # ${family} the family of the chart
871
- # ${url_family} same as ${family} but URL encoded
870
# ${status} the current status : REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL
871
# ${old_status} the previous status: REMOVED, UNINITIALIZED, UNDEFINED, CLEAR, WARNING, CRITICAL
872
# ${value} the current value of the alarm
libnetdata/health/health.c
+5
-11
@@ -29,8 +29,8 @@ void health_silencers_add(SILENCER *silencer) {
29
// Add the created instance to the linked list in silencers
30
silencer->next = silencers->silencers;
31
silencers->silencers = silencer;
32
- netdata_log_debug(D_HEALTH, "HEALTH command API: Added silencer %s:%s:%s:%s:%s", silencer->alarms,
33
- silencer->charts, silencer->contexts, silencer->hosts, silencer->families
32
+ netdata_log_debug(D_HEALTH, "HEALTH command API: Added silencer %s:%s:%s:%s", silencer->alarms,
33
+ silencer->charts, silencer->contexts, silencer->hosts
34
);
35
}
36
@@ -51,8 +51,7 @@ SILENCER *health_silencers_addparam(SILENCER *silencer, char *key, char *value)
51
hash_template = 0,
52
hash_chart = 0,
53
hash_context = 0,
54
- hash_host = 0,
55
- hash_families = 0;
54
+ hash_host = 0;
55
56
if (unlikely(!hash_alarm)) {
57
hash_alarm = simple_uhash(HEALTH_ALARM_KEY);
@@ -60,7 +59,6 @@ SILENCER *health_silencers_addparam(SILENCER *silencer, char *key, char *value)
59
hash_chart = simple_uhash(HEALTH_CHART_KEY);
60
hash_context = simple_uhash(HEALTH_CONTEXT_KEY);
61
hash_host = simple_uhash(HEALTH_HOST_KEY);
63
- hash_families = simple_uhash(HEALTH_FAMILIES_KEY);
62
}
63
64
uint32_t hash = simple_uhash(key);
@@ -70,8 +68,7 @@ SILENCER *health_silencers_addparam(SILENCER *silencer, char *key, char *value)
68
(hash == hash_template && !strcasecmp(key, HEALTH_TEMPLATE_KEY)) ||
69
(hash == hash_chart && !strcasecmp(key, HEALTH_CHART_KEY)) ||
70
(hash == hash_context && !strcasecmp(key, HEALTH_CONTEXT_KEY)) ||
73
- (hash == hash_host && !strcasecmp(key, HEALTH_HOST_KEY)) ||
74
- (hash == hash_families && !strcasecmp(key, HEALTH_FAMILIES_KEY))
71
+ (hash == hash_host && !strcasecmp(key, HEALTH_HOST_KEY))
72
) {
73
silencer = create_silencer();
74
if(!silencer) {
@@ -93,9 +90,6 @@ SILENCER *health_silencers_addparam(SILENCER *silencer, char *key, char *value)
90
} else if (hash == hash_host && !strcasecmp(key, HEALTH_HOST_KEY)) {
91
silencer->hosts = strdupz(value);
92
silencer->hosts_pattern = simple_pattern_create(silencer->hosts, NULL, SIMPLE_PATTERN_EXACT, true);
96
- } else if (hash == hash_families && !strcasecmp(key, HEALTH_FAMILIES_KEY)) {
97
- silencer->families = strdupz(value);
98
- silencer->families_pattern = simple_pattern_create(silencer->families, NULL, SIMPLE_PATTERN_EXACT, true);
93
}
94
95
return silencer;
@@ -172,4 +166,4 @@ int health_initialize_global_silencers() {
166
silencers->silencers=NULL;
167
168
return 0;
175
-}
\ No newline at end of file
169
+}
libnetdata/health/health.h
-4
@@ -11,7 +11,6 @@
11
#define HEALTH_CHART_KEY "chart"
12
#define HEALTH_HOST_KEY "hosts"
13
#define HEALTH_OS_KEY "os"
14
-#define HEALTH_FAMILIES_KEY "families"
14
#define HEALTH_LOOKUP_KEY "lookup"
15
#define HEALTH_CALC_KEY "calc"
16
@@ -28,9 +27,6 @@ typedef struct silencer {
27
char *charts;
28
SIMPLE_PATTERN *charts_pattern;
29
31
- char *families;
32
- SIMPLE_PATTERN *families_pattern;
33
-
30
struct silencer *next;
31
} SILENCER;
32
tests/health_mgmtapi/health-cmdapi-test.sh.in
-6
@@ -190,12 +190,6 @@ err=0
190
cmd "cmd=RESET" "$HEALTH_CMDAPI_MSG_RESET"
191
check_list "RESET"
192
193
- # Add silencer without a command to disable or silence alarms
194
- printf -v resp "$HEALTH_CMDAPI_MSG_ADDED\n$HEALTH_CMDAPI_MSG_STYPEWARNING"
195
- cmd "families=load" "${resp}"
196
- check "Family selector with no command" "False False False False False False"
197
- check_list "FAMILIES_LOAD"
198
-
193
# Add silence command
194
cmd "cmd=SILENCE" "$HEALTH_CMDAPI_MSG_SILENCE"
195
check "Silence family load" "False False False False False True"
web/api/health/README.md
+1
-8
@@ -61,7 +61,7 @@ Specifically, the API allows you to:
61
62
- Disable health checks completely. Alert conditions will not be evaluated at all and no entries will be added to the alert log.
63
- Silence alert notifications. Alert conditions will be evaluated, the alerts will appear in the log and the Netdata UI will show the alerts as active, but no notifications will be sent.
64
-- Disable or Silence specific alerts that match selectors on alert/template name, chart, context, host and family.
64
+- Disable or Silence specific alerts that match selectors on alert/template name, chart, context, and host.
65
66
The API is available by default, but it is protected by an `api authorization token` that is stored in the file you will see in the following entry of `http://NODE:19999/netdata.conf`:
67
@@ -138,7 +138,6 @@ The accepted keys for the `selection criteria` are the following:
138
- `chart` : Chart ids/names, as shown on the dashboard. These will match the `on` entry of a configured `alarm`.
139
- `context` : Chart context, as shown on the dashboard. These will match the `on` entry of a configured `template`.
140
- `hosts` : The hostnames that will need to match.
141
-- `families` : The alert families.
141
142
You can add any of the selection criteria you need on the request, to ensure that only the alerts you are interested in are matched and disabled/silenced. e.g. there is no reason to add `hosts: *`, if you want the criteria to be applied to alerts for all hosts.
143
@@ -154,12 +153,6 @@ Example 2: Silence all alerts and templates with name starting with `out_of` on
153
http://NODE:19999/api/v1/manage/health?cmd=SILENCE&alarm=out_of*&hosts=myhost
154
```
155
157
-Example 2.2: Add one more selector, to also silence alerts for cpu1 and cpu2
158
-
159
-```
160
-http://NODE:19999/api/v1/manage/health?families=cpu1 cpu2
161
-```
162
-
156
### List silencers
157
158
The command `LIST` was added in Netdata v1.16.0 and returns a JSON with the current status of the silencers.
web/api/health/health_cmdapi.c
+3
-5
@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-3.0-or-later
2
//
3
// Created by Christopher on 11/12/18.
4
//
@@ -14,18 +15,16 @@
15
void free_silencers(SILENCER *t) {
16
if (!t) return;
17
if (t->next) free_silencers(t->next);
17
- netdata_log_debug(D_HEALTH, "HEALTH command API: Freeing silencer %s:%s:%s:%s:%s", t->alarms,
18
- t->charts, t->contexts, t->hosts, t->families);
18
+ netdata_log_debug(D_HEALTH, "HEALTH command API: Freeing silencer %s:%s:%s:%s", t->alarms,
19
+ t->charts, t->contexts, t->hosts);
20
simple_pattern_free(t->alarms_pattern);
21
simple_pattern_free(t->charts_pattern);
22
simple_pattern_free(t->contexts_pattern);
23
simple_pattern_free(t->hosts_pattern);
23
- simple_pattern_free(t->families_pattern);
24
freez(t->alarms);
25
freez(t->charts);
26
freez(t->contexts);
27
freez(t->hosts);
28
- freez(t->families);
28
freez(t);
29
return;
30
}
@@ -74,7 +73,6 @@ void health_silencers2json(BUFFER *wb) {
73
j=health_silencers2json_entry(wb, HEALTH_CHART_KEY, silencer->charts, j);
74
j=health_silencers2json_entry(wb, HEALTH_CONTEXT_KEY, silencer->contexts, j);
75
j=health_silencers2json_entry(wb, HEALTH_HOST_KEY, silencer->hosts, j);
77
- health_silencers2json_entry(wb, HEALTH_FAMILIES_KEY, silencer->families, j);
76
j=0;
77
buffer_strcat(wb, "\n\t\t}");
78
i++;
web/api/netdata-swagger.json
+1
-9
@@ -1645,14 +1645,6 @@
1645
"schema": {
1646
"type": "string"
1647
}
1648
- },
1649
- {
1650
- "name": "families",
1651
- "in": "query",
1652
- "description": "The alarm families.",
1653
- "schema": {
1654
- "type": "string"
1655
- }
1648
}
1649
],
1650
"responses": {
@@ -4426,4 +4418,4 @@
4418
}
4419
}
4420
}
4429
-}
\ No newline at end of file
4421
+}
web/api/netdata-swagger.yaml
-5
@@ -1059,11 +1059,6 @@ paths:
1059
description: The hostnames that will need to match.
1060
schema:
1061
type: string
1062
- - name: families
1063
- in: query
1064
- description: The alarm families.
1065
- schema:
1066
- type: string
1062
responses:
1063
"200":
1064
description: A plain text response based on the result of the command.