summaryrefslogtreecommitdiffstats
path: root/src/health
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@netdata.cloud>2024-03-05 12:11:56 +0200
committerGitHub <noreply@github.com>2024-03-05 12:11:56 +0200
commita0e176013a740590d9556cac5c30d64a7b4f437d (patch)
tree823111fa0f8a92f25c68b41cb5ef3a5b73c7287e /src/health
parentc6e1db8dce6635b38e4ea2379388c6a0a8cdcecd (diff)
HEALTH: eliminate fields that should be labels (#17048)
* eliminate fields that should be labels * remaining * remove comma * add _os and _hostname host labels * systemd-journal dynamic configuration updates * move systemd-journal dynamic configuration to logs * copied and integrated rrdlabels update from #16953 * strict type checking on SIMPLE_PATTERN and fixes for wrong uses * add _os and _hostname on children that do not advertise them * remove instance names support for alerts * removed charts and families from docs * Adjust alert config store statement * Remove os, host, plugin, module, charts from alert configuration * Fix compilation warning, remove unused keys (charts, foreach) --------- Co-authored-by: Stelios Fragkakis <52996999+stelfrag@users.noreply.github.com>
Diffstat (limited to 'src/health')
-rw-r--r--src/health/REFERENCE.md18
-rw-r--r--src/health/health_config.c59
-rw-r--r--src/health/health_dyncfg.c13
-rw-r--r--src/health/health_internals.h2
-rw-r--r--src/health/health_prototypes.c148
-rw-r--r--src/health/health_prototypes.h14
-rw-r--r--src/health/rrdcalc.c37
-rw-r--r--src/health/schema.d/health:alert:prototype.json53
8 files changed, 103 insertions, 241 deletions
diff --git a/src/health/REFERENCE.md b/src/health/REFERENCE.md
index ee46b8daa9..4888661f12 100644
--- a/src/health/REFERENCE.md
+++ b/src/health/REFERENCE.md
@@ -242,7 +242,6 @@ Netdata parses the following lines. Beneath the table is an in-depth explanation
| [`hosts`](#alert-line-hosts) | no | Which hostnames will run this alert. |
| [`plugin`](#alert-line-plugin) | no | Restrict an alert or template to only a certain plugin. |
| [`module`](#alert-line-module) | no | Restrict an alert or template to only a certain module. |
-| [`charts`](#alert-line-charts) | no | Restrict an alert or template to only certain charts. |
| [`lookup`](#alert-line-lookup) | yes | The database lookup to find and process metrics for the chart specified through `on`. |
| [`calc`](#alert-line-calc) | yes (see above) | A calculation to apply to the value found via `lookup` or another variable. |
| [`every`](#alert-line-every) | no | The frequency of the alert. |
@@ -433,19 +432,6 @@ plugin: python.d.plugin
module: isc_dhcpd
```
-#### Alert line `charts`
-
-The `charts` line filters which chart this alert should apply to. It is only available on entities using the
-[`template`](#alert-line-alarm-or-template) line.
-The value is a space-separated list of [simple patterns](https://github.com/netdata/netdata/blob/master/src/libnetdata/simple_pattern/README.md). For
-example, a template that applies to `disk.svctm` (Average Service Time) context, but excludes the disk `sdb` from alerts:
-
-```yaml
-template: disk_svctm_alert
- on: disk.svctm
- charts: !*sdb* *
-```
-
#### Alert line `lookup`
This line makes a database lookup to find a value. This result of this lookup is available as `$this`.
@@ -897,10 +883,6 @@ context are essentially identical, with the only difference being the family tha
that resolves to unix timestamp the dimension was last collected (there may be dimensions
that fail to be collected while others continue normally).
-- **family variables**. Families are used to group charts together. For example all `eth0`
- charts, have `family = eth0`. This index includes all local variables, but if there are
- overlapping variables, only the first are exposed.
-
- **host variables**. All the dimensions of all charts, including all alerts, in fullname.
Fullname is `CHART.VARIABLE`, where `CHART` is either the chart id or the chart name (both
are supported).
diff --git a/src/health/health_config.c b/src/health/health_config.c
index fafc1d0b05..948f263a0b 100644
--- a/src/health/health_config.c
+++ b/src/health/health_config.c
@@ -340,7 +340,7 @@ static inline void strip_quotes(char *s) {
}
}
-#define PARSE_HEALTH_CONFIG_DUPLICATE_STRING_MSG(ax, member) do { \
+#define PARSE_HEALTH_CONFIG_LOG_DUPLICATE_STRING_MSG(ax, member) do { \
if(strcmp(string2str(ax->member), value) != 0) \
netdata_log_error( \
"Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' twice, " \
@@ -351,26 +351,48 @@ static inline void strip_quotes(char *s) {
#define PARSE_HEALTH_CONFIG_LINE_STRING(ax, member) do { \
if(ax->member) { \
- PARSE_HEALTH_CONFIG_DUPLICATE_STRING_MSG(ax, member); \
+ PARSE_HEALTH_CONFIG_LOG_DUPLICATE_STRING_MSG(ax, member); \
string_freez(ax->member); \
} \
ax->member = string_strdupz(value); \
} while(0)
-#define PARSE_HEALTH_CONFIG_LINE_PATTERN(ax, member) do { \
- if(ax->member) { \
- PARSE_HEALTH_CONFIG_DUPLICATE_STRING_MSG(ax, member); \
- string_freez(ax->member); \
- } \
- if(value && strcmp(value, "*") == 0) \
+#define PARSE_HEALTH_CONFIG_LINE_PATTERN_APPEND(ax, member, label) do { \
+ const char *_label = label; \
+ if(_label && !*_label) \
+ _label = NULL; \
+ \
+ if(value && (!*value || strcmp(value, "*") == 0)) \
value = NULL; \
else if(value && (strcmp(value, "!* *") == 0 || strcmp(value, "!*") == 0)) { \
value = NULL; \
ap->match.enabled = false; \
} \
- ax->member = string_strdupz(value); \
+ \
+ if(value && !_label && !strchr(value, '=')) { \
+ netdata_log_error( \
+ "Health configuration at line %zu of file '%s' for alarm '%s' has key '%s' " \
+ "with value '%s' that does not match label=pattern. Ignoring it.", \
+ line, filename, string2str(ac->name), key, value); \
+ value = NULL; \
+ } \
+ \
+ if(value) { \
+ typeof(ax->member) _old = ax->member; \
+ char _buf[strlen(value) + string_strlen(_old) + (_label ? strlen(_label) : 0) + 3]; \
+ snprintfz(_buf, sizeof(_buf), "%s%s%s%s%s", \
+ _label ? _label : "", \
+ _label ? "=" : "", \
+ value, \
+ _old ? " " : "", \
+ _old ? string2str(_old) : ""); \
+ string_freez(_old); \
+ ax->member = string_strdupz(_buf); \
+ } \
} while(0)
+
+
int health_readfile(const char *filename, void *data __maybe_unused, bool stock_config) {
netdata_log_debug(D_HEALTH, "Health configuration reading file '%s'", filename);
@@ -382,7 +404,6 @@ int health_readfile(const char *filename, void *data __maybe_unused, bool stock_
hash_host = 0,
hash_plugin = 0,
hash_module = 0,
- hash_charts = 0,
hash_calc = 0,
hash_green = 0,
hash_red = 0,
@@ -414,7 +435,6 @@ int health_readfile(const char *filename, void *data __maybe_unused, bool stock_
hash_host = simple_uhash(HEALTH_HOST_KEY);
hash_plugin = simple_uhash(HEALTH_PLUGIN_KEY);
hash_module = simple_uhash(HEALTH_MODULE_KEY);
- hash_charts = simple_uhash(HEALTH_CHARTS_KEY);
hash_calc = simple_uhash(HEALTH_CALC_KEY);
hash_lookup = simple_uhash(HEALTH_LOOKUP_KEY);
hash_green = simple_uhash(HEALTH_GREEN_KEY);
@@ -542,26 +562,23 @@ int health_readfile(const char *filename, void *data __maybe_unused, bool stock_
else if(am->is_template && hash == hash_on && !strcasecmp(key, HEALTH_ON_KEY)) {
PARSE_HEALTH_CONFIG_LINE_STRING(am, on.context);
}
- else if(am->is_template && hash == hash_charts && !strcasecmp(key, HEALTH_CHARTS_KEY)) {
- PARSE_HEALTH_CONFIG_LINE_PATTERN(am, charts);
- }
else if(hash == hash_os && !strcasecmp(key, HEALTH_OS_KEY)) {
- PARSE_HEALTH_CONFIG_LINE_PATTERN(am, os);
+ PARSE_HEALTH_CONFIG_LINE_PATTERN_APPEND(am, host_labels, "_os");
}
else if(hash == hash_host && !strcasecmp(key, HEALTH_HOST_KEY)) {
- PARSE_HEALTH_CONFIG_LINE_PATTERN(am, host);
+ PARSE_HEALTH_CONFIG_LINE_PATTERN_APPEND(am, host_labels, "_hostname");
}
else if(hash == hash_host_label && !strcasecmp(key, HEALTH_HOST_LABEL_KEY)) {
- PARSE_HEALTH_CONFIG_LINE_PATTERN(am, host_labels);
+ PARSE_HEALTH_CONFIG_LINE_PATTERN_APPEND(am, host_labels, NULL);
}
else if(hash == hash_plugin && !strcasecmp(key, HEALTH_PLUGIN_KEY)) {
- PARSE_HEALTH_CONFIG_LINE_PATTERN(am, plugin);
+ PARSE_HEALTH_CONFIG_LINE_PATTERN_APPEND(am, chart_labels, "_collect_plugin");
}
else if(hash == hash_module && !strcasecmp(key, HEALTH_MODULE_KEY)) {
- PARSE_HEALTH_CONFIG_LINE_PATTERN(am, module);
+ PARSE_HEALTH_CONFIG_LINE_PATTERN_APPEND(am, chart_labels, "_collect_module");
}
else if(hash == hash_chart_label && !strcasecmp(key, HEALTH_CHART_LABEL_KEY)) {
- PARSE_HEALTH_CONFIG_LINE_PATTERN(am, chart_labels);
+ PARSE_HEALTH_CONFIG_LINE_PATTERN_APPEND(am, chart_labels, NULL);
}
else if(hash == hash_class && !strcasecmp(key, HEALTH_CLASS_KEY)) {
strip_quotes(value);
@@ -680,7 +697,7 @@ int health_readfile(const char *filename, void *data __maybe_unused, bool stock_
ac->has_custom_repeat_config = true;
}
else {
- if (strcmp(key, "families") != 0)
+ if (strcmp(key, "families") != 0 && strcmp(key, "charts") != 0)
netdata_log_error(
"Health configuration at line %zu of file '%s' for alarm/template '%s' has unknown key '%s'.",
line, filename, string2str(ac->name), key);
diff --git a/src/health/health_dyncfg.c b/src/health/health_dyncfg.c
index b111d715ee..d5261773e1 100644
--- a/src/health/health_dyncfg.c
+++ b/src/health/health_dyncfg.c
@@ -17,14 +17,6 @@ static bool parse_match(json_object *jobj, const char *path, struct rrd_alert_ma
else
match->on.chart = on;
- JSONC_PARSE_TXT2PATTERN_OR_ERROR_AND_RETURN(jobj, path, "os", match->os, error);
- JSONC_PARSE_TXT2PATTERN_OR_ERROR_AND_RETURN(jobj, path, "host", match->host, error);
-
- if(match->is_template)
- JSONC_PARSE_TXT2PATTERN_OR_ERROR_AND_RETURN(jobj, path, "instances", match->charts, error);
-
- JSONC_PARSE_TXT2PATTERN_OR_ERROR_AND_RETURN(jobj, path, "plugin", match->plugin, error);
- JSONC_PARSE_TXT2PATTERN_OR_ERROR_AND_RETURN(jobj, path, "module", match->module, error);
JSONC_PARSE_TXT2PATTERN_OR_ERROR_AND_RETURN(jobj, path, "host_labels", match->host_labels, error);
JSONC_PARSE_TXT2PATTERN_OR_ERROR_AND_RETURN(jobj, path, "instance_labels", match->chart_labels, error);
@@ -219,11 +211,6 @@ static inline void health_prototype_rule_to_json_array_member(BUFFER *wb, RRD_AL
else
buffer_json_member_add_string(wb, "on", string2str(ap->match.on.chart));
- buffer_json_member_add_string_or_empty(wb, "os", ap->match.os ? string2str(ap->match.os) : "*");
- buffer_json_member_add_string_or_empty(wb, "host", ap->match.host ? string2str(ap->match.host) : "*");
- buffer_json_member_add_string_or_empty(wb, "instances", ap->match.charts ? string2str(ap->match.charts) : "*");
- buffer_json_member_add_string_or_empty(wb, "plugin", ap->match.charts ? string2str(ap->match.plugin) : "*");
- buffer_json_member_add_string_or_empty(wb, "module", ap->match.module ? string2str(ap->match.module) : "*");
buffer_json_member_add_string_or_empty(wb, "host_labels", ap->match.host_labels ? string2str(ap->match.host_labels) : "*");
buffer_json_member_add_string_or_empty(wb, "instance_labels", ap->match.chart_labels ? string2str(ap->match.chart_labels) : "*");
}
diff --git a/src/health/health_internals.h b/src/health/health_internals.h
index 78e391030a..d24a2422b3 100644
--- a/src/health/health_internals.h
+++ b/src/health/health_internals.h
@@ -22,7 +22,6 @@
#define HEALTH_OS_KEY "os"
#define HEALTH_PLUGIN_KEY "plugin"
#define HEALTH_MODULE_KEY "module"
-#define HEALTH_CHARTS_KEY "charts"
#define HEALTH_LOOKUP_KEY "lookup"
#define HEALTH_CALC_KEY "calc"
#define HEALTH_EVERY_KEY "every"
@@ -42,7 +41,6 @@
#define HEALTH_OPTIONS_KEY "options"
#define HEALTH_REPEAT_KEY "repeat"
#define HEALTH_HOST_LABEL_KEY "host labels"
-#define HEALTH_FOREACH_KEY "foreach"
#define HEALTH_CHART_LABEL_KEY "chart labels"
void alert_action_options_to_buffer_json_array(BUFFER *wb, const char *key, ALERT_ACTION_OPTIONS options);
diff --git a/src/health/health_prototypes.c b/src/health/health_prototypes.c
index 6775ea56f6..84c6c9cde4 100644
--- a/src/health/health_prototypes.c
+++ b/src/health/health_prototypes.c
@@ -166,16 +166,20 @@ void health_init_prototypes(void) {
// ---------------------------------------------------------------------------------------------------------------------
-// If needed, add a prefix key to all possible values in the range
-static inline char *health_config_add_key_to_values(char *value) {
- BUFFER *wb = buffer_create(HEALTH_CONF_MAX_LINE + 1, NULL);
+static inline struct pattern_array *health_config_add_key_to_values(struct pattern_array *pa, const char *input_key, char *value)
+{
char key[HEALTH_CONF_MAX_LINE + 1];
char data[HEALTH_CONF_MAX_LINE + 1];
char *s = value;
size_t i = 0;
- key[0] = '\0';
+ char pair[HEALTH_CONF_MAX_LINE + 1];
+ if (input_key)
+ strncpyz(key, input_key, HEALTH_CONF_MAX_LINE);
+ else
+ key[0] = '\0';
+
while(*s) {
if (*s == '=') {
//hold the key
@@ -185,94 +189,69 @@ static inline char *health_config_add_key_to_values(char *value) {
} else if (*s == ' ') {
data[i]='\0';
if (data[0]=='!')
- buffer_snprintf(wb, HEALTH_CONF_MAX_LINE, "!%s=%s ", key, data + 1);
+ snprintfz(pair, HEALTH_CONF_MAX_LINE, "!%s=%s ", key, data + 1);
else
- buffer_snprintf(wb, HEALTH_CONF_MAX_LINE, "%s=%s ", key, data);
+ snprintfz(pair, HEALTH_CONF_MAX_LINE, "%s=%s ", key, data);
+
+ pa = pattern_array_add_key_simple_pattern(pa, key, simple_pattern_create(pair, NULL, SIMPLE_PATTERN_EXACT, true));
i=0;
} else {
data[i++] = *s;
}
s++;
}
-
data[i]='\0';
if (data[0]) {
if (data[0]=='!')
- buffer_snprintf(wb, HEALTH_CONF_MAX_LINE, "!%s=%s ", key, data + 1);
+ snprintfz(pair, HEALTH_CONF_MAX_LINE, "!%s=%s ", key, data + 1);
else
- buffer_snprintf(wb, HEALTH_CONF_MAX_LINE, "%s=%s ", key, data);
- }
-
- char *final = strdupz(buffer_tostring(wb));
- buffer_free(wb);
-
- return final;
-}
+ snprintfz(pair, HEALTH_CONF_MAX_LINE, "%s=%s ", key, data);
-static void health_prototype_activate_match_patterns(struct rrd_alert_match *am) {
- if(am->os) {
- simple_pattern_free(am->os_pattern);
-
- char *tmp = simple_pattern_trim_around_equal(string2str(am->os));
- am->os_pattern = simple_pattern_create(
- tmp, NULL, SIMPLE_PATTERN_EXACT, true);
- freez(tmp);
+ pa = pattern_array_add_key_simple_pattern(pa, key, simple_pattern_create(pair, NULL, SIMPLE_PATTERN_EXACT, true));
}
- if(am->host) {
- simple_pattern_free(am->host_pattern);
-
- char *tmp = simple_pattern_trim_around_equal(string2str(am->host));
- am->host_pattern = simple_pattern_create(
- tmp, NULL, SIMPLE_PATTERN_EXACT, true);
- freez(tmp);
- }
+ return pa;
+}
- if(am->charts) {
- simple_pattern_free(am->charts_pattern);
+static char *simple_pattern_trim_around_equal(const char *src) {
+ char *store = mallocz(strlen(src) + 1);
- char *tmp = simple_pattern_trim_around_equal(string2str(am->charts));
- am->charts_pattern = simple_pattern_create(
- tmp, NULL, SIMPLE_PATTERN_EXACT, true);
- freez(tmp);
- }
+ char *dst = store;
+ while (*src) {
+ if (*src == '=') {
+ if (*(dst -1) == ' ')
+ dst--;
- if(am->plugin) {
- simple_pattern_free(am->plugin_pattern);
+ *dst++ = *src++;
+ if (*src == ' ')
+ src++;
+ }
- char *tmp = simple_pattern_trim_around_equal(string2str(am->plugin));
- am->plugin_pattern = simple_pattern_create(
- tmp, NULL, SIMPLE_PATTERN_EXACT, true);
- freez(tmp);
+ *dst++ = *src++;
}
+ *dst = 0x00;
- if(am->module) {
- simple_pattern_free(am->module_pattern);
+ return store;
+}
- char *tmp = simple_pattern_trim_around_equal(string2str(am->module));
- am->module_pattern = simple_pattern_create(
- tmp, NULL, SIMPLE_PATTERN_EXACT, true);
- freez(tmp);
- }
+static struct pattern_array *trim_and_add_key_to_values(struct pattern_array *pa, const char *key, STRING *input) {
+ char *tmp = simple_pattern_trim_around_equal(string2str(input));
+ pa = health_config_add_key_to_values(pa, key, tmp);
+ freez(tmp);
+ return pa;
+}
+static void health_prototype_activate_match_patterns(struct rrd_alert_match *am) {
if(am->host_labels) {
- simple_pattern_free(am->host_labels_pattern);
-
- char *tmp = simple_pattern_trim_around_equal(string2str(am->host_labels));
- am->host_labels_pattern = simple_pattern_create(
- tmp, NULL, SIMPLE_PATTERN_EXACT, true);
- freez(tmp);
+ pattern_array_free(am->host_labels_pattern);
+ am->host_labels_pattern = NULL;
+ am->host_labels_pattern = trim_and_add_key_to_values(am->host_labels_pattern, NULL, am->host_labels);
}
if(am->chart_labels) {
- simple_pattern_free(am->chart_labels_pattern);
-
- char *tmp = simple_pattern_trim_around_equal(string2str(am->chart_labels));
- char *tmp2 = health_config_add_key_to_values(tmp);
- am->chart_labels_pattern = simple_pattern_create(
- tmp2, NULL, SIMPLE_PATTERN_EXACT, true);
- freez(tmp2);
- freez(tmp);
+ pattern_array_free(am->chart_labels_pattern);
+ am->chart_labels_pattern = NULL;
+ am->chart_labels_pattern = trim_and_add_key_to_values(am->chart_labels_pattern, NULL, am->chart_labels);
}
}
@@ -387,15 +366,8 @@ static bool prototype_matches_host(RRDHOST *host, RRD_ALERT_PROTOTYPE *ap) {
!simple_pattern_matches(health_globals.config.enabled_alerts, string2str(ap->config.name)))
return false;
- if(ap->match.os_pattern && !simple_pattern_matches_string(ap->match.os_pattern, host->os))
- return false;
-
- if(ap->match.host_pattern && !simple_pattern_matches_string(ap->match.host_pattern, host->hostname))
- return false;
-
- if(host->rrdlabels && ap->match.host_labels_pattern &&
- !rrdlabels_match_simple_pattern_parsed(
- host->rrdlabels, ap->match.host_labels_pattern, '=', NULL))
+ if (host->rrdlabels && ap->match.host_labels_pattern &&
+ !pattern_array_label_match(ap->match.host_labels_pattern, host->rrdlabels, '=', NULL, rrdlabels_match_simple_pattern_parsed))
return false;
return true;
@@ -412,25 +384,8 @@ static bool prototype_matches_rrdset(RRDSET *st, RRD_ALERT_PROTOTYPE *ap) {
ap->match.on.context != st->context)
return false;
- // match the chart pattern
- if(ap->match.is_template && ap->match.charts && ap->match.charts_pattern &&
- !simple_pattern_matches_string(ap->match.charts_pattern, st->id) &&
- !simple_pattern_matches_string(ap->match.charts_pattern, st->name))
- return false;
-
- // match the plugin pattern
- if(ap->match.plugin && ap->match.plugin_pattern &&
- !simple_pattern_matches_string(ap->match.plugin_pattern, st->plugin_name))
- return false;
-
- // match the module pattern
- if(ap->match.module && ap->match.module_pattern &&
- !simple_pattern_matches_string(ap->match.module_pattern, st->module_name))
- return false;
-
- if (st->rrdlabels && ap->match.chart_labels && ap->match.chart_labels_pattern &&
- !rrdlabels_match_simple_pattern_parsed(
- st->rrdlabels, ap->match.chart_labels_pattern, '=', NULL))
+ if (st->rrdlabels && ap->match.chart_labels_pattern &&
+ !pattern_array_label_match(ap->match.chart_labels_pattern, st->rrdlabels, '=', NULL, rrdlabels_match_simple_pattern_parsed))
return false;
return true;
@@ -445,11 +400,6 @@ void health_prototype_copy_match_without_patterns(struct rrd_alert_match *dst, s
else
dst->on.chart = string_dup(src->on.chart);
- dst->os = string_dup(src->os);
- dst->host = string_dup(src->host);
- dst->charts = string_dup(src->charts);
- dst->plugin = string_dup(src->plugin);
- dst->module = string_dup(src->module);
dst->host_labels = string_dup(src->host_labels);
dst->chart_labels = string_dup(src->chart_labels);
}
diff --git a/src/health/health_prototypes.h b/src/health/health_prototypes.h
index c5f5b18376..302810bf9a 100644
--- a/src/health/health_prototypes.h
+++ b/src/health/health_prototypes.h
@@ -19,21 +19,11 @@ struct rrd_alert_match {
STRING *context;
} on;
- STRING *os;
- STRING *host;
- STRING *charts; // the charts that should be linked to (for templates)
- STRING *plugin; // the plugin name that should be linked to
- STRING *module; // the module name that should be linked to
STRING *host_labels; // the label read from an alarm file
STRING *chart_labels; // the chart label read from an alarm file
- SIMPLE_PATTERN *os_pattern;
- SIMPLE_PATTERN *host_pattern;
- SIMPLE_PATTERN *charts_pattern; // the simple pattern of charts
- SIMPLE_PATTERN *plugin_pattern; // the simple pattern of plugin
- SIMPLE_PATTERN *module_pattern; // the simple pattern of module
- SIMPLE_PATTERN *host_labels_pattern; // the simple pattern of labels
- SIMPLE_PATTERN *chart_labels_pattern; // the simple pattern of chart labels
+ struct pattern_array *host_labels_pattern;
+ struct pattern_array *chart_labels_pattern;
};
void rrd_alert_match_cleanup(struct rrd_alert_match *am);
diff --git a/src/health/rrdcalc.c b/src/health/rrdcalc.c
index 09576bae87..fa6a884718 100644
--- a/src/health/rrdcalc.c
+++ b/src/health/rrdcalc.c
@@ -289,24 +289,6 @@ static void rrdcalc_unlink_from_rrdset(RRDCALC *rc, bool having_ll_wrlock) {
rc->rrdset = NULL;
}
-static inline bool rrdcalc_check_if_it_matches_rrdset(RRDCALC *rc, RRDSET *st) {
- if ( (rc->chart != st->id)
- && (rc->chart != st->name))
- return false;
-
- if (rc->match.module_pattern && !simple_pattern_matches_string(rc->match.module_pattern, st->module_name))
- return false;
-
- if (rc->match.plugin_pattern && !simple_pattern_matches_string(rc->match.plugin_pattern, st->module_name))
- return false;
-
- if (st->rrdlabels && rc->match.chart_labels_pattern && !rrdlabels_match_simple_pattern_parsed(
- st->rrdlabels, rc->match.chart_labels_pattern, '=', NULL))
- return false;
-
- return true;
-}
-
// ----------------------------------------------------------------------------
// RRDCALC rrdhost index management - constructor
@@ -493,26 +475,11 @@ void rrd_alert_match_cleanup(struct rrd_alert_match *am) {
else
string_freez(am->on.chart);
- string_freez(am->os);
- simple_pattern_free(am->os_pattern);
-
- string_freez(am->host);
- simple_pattern_free(am->host_pattern);
-
- string_freez(am->plugin);
- simple_pattern_free(am->plugin_pattern);
-
- string_freez(am->module);
- simple_pattern_free(am->module_pattern);
-
- string_freez(am->charts);
- simple_pattern_free(am->charts_pattern);
-
string_freez(am->host_labels);
- simple_pattern_free(am->host_labels_pattern);
+ pattern_array_free(am->host_labels_pattern);
string_freez(am->chart_labels);
- simple_pattern_free(am->chart_labels_pattern);
+ pattern_array_free(am->chart_labels_pattern);
}
void rrd_alert_config_cleanup(struct rrd_alert_config *ac) {
diff --git a/src/health/schema.d/health:alert:prototype.json b/src/health/schema.d/health:alert:prototype.json
index 9e0baaaef5..a2d8b1b40c 100644
--- a/src/health/schema.d/health:alert:prototype.json
+++ b/src/health/schema.d/health:alert:prototype.json
@@ -12,11 +12,6 @@
"default": "*",
"title": "Only for nodes with these host labels"
},
- "matchHostnames": {
- "type": "string",
- "default": "*",
- "title": "Only for these hostnames"
- },
"matchInstance": {
"type": "object",
"title": "Apply this rule to a single instance",
@@ -29,15 +24,10 @@
"description": "You can find the instance names on all charts at the instances drop down menu. Do not include the host name in this field."
},
"host_labels": { "$ref": "#/definitions/matchHostLabels" },
- "host": { "$ref": "#/definitions/matchHostnames" },
"instance_labels": { "$ref": "#/definitions/matchInstanceLabels" }
},
"required": [
"on",
- "os",
- "host",
- "plugin",
- "module",
"host_labels",
"instance_labels"
]
@@ -54,22 +44,11 @@
"description": "The context is the code-name of each chart on the dashboard, that appears at the chart title bar, between the chart title and its unit of measurement, like: system.cpu, disk.io, etc."
},
"host_labels": { "$ref": "#/definitions/matchHostLabels" },
- "host": { "$ref": "#/definitions/matchHostnames" },
- "instance_labels": { "$ref": "#/definitions/matchInstanceLabels" },
- "instances": {
- "type": "string",
- "default": "*",
- "title": "On on these instances"
- }
+ "instance_labels": { "$ref": "#/definitions/matchInstanceLabels" }
},
"required": [
"on",
- "os",
- "host",
- "plugin",
- "module",
"host_labels",
- "instances",
"instance_labels"
]
},
@@ -105,7 +84,7 @@
},
"value": {
"type": "object",
- "title": "Alert Value Calculation",
+ "title": "",
"description": "Each alert has a value. This section defines how this value is calculated.",
"properties": {
"database_lookup": {
@@ -210,7 +189,7 @@
},
"conditions": {
"type": "object",
- "title": "Conditions to trigger the alert",
+ "title": "",
"properties": {
"warning_condition": {
"type": "string",
@@ -242,7 +221,7 @@
},
"action": {
"type": "object",
- "title": "Alert Action (notification or automation)",
+ "title": "",
"description": "The action the alert should take when it transitions states",
"properties": {
"execute": {
@@ -393,19 +372,11 @@
},
"host_labels": {
"ui:help": "A simple pattern to match the node labels of the nodes this rule is to be applied to. A space separated list of label=value pairs is accepted. Asterisks can be placed anywhere, including the label key. The label keys and their values are available at the labels filter of the charts on the dashboard.",
- "ui:classNames": "dyncfg-grid-col-span-1-4"
- },
- "host": {
- "ui:classNames": "dyncfg-grid-col-span-5-2",
- "ui:help": "A simple pattern to match the hostnames of the nodes this rule is to be applied to."
+ "ui:classNames": "dyncfg-grid-col-span-1-3"
},
"instance_labels": {
- "ui:classNames": "dyncfg-grid-col-span-1-4",
+ "ui:classNames": "dyncfg-grid-col-span-4-3",
"ui:help": "A simple pattern to match the instance labels of the instances this rule is to be applied to. A space separated list of label=value pairs is accepted. Asterisks can be placed anywhere, including the label key. The label keys and their values are available at the labels filter of the charts on the dashboard."
- },
- "instances": {
- "ui:classNames": "dyncfg-grid-col-span-5-2",
- "ui:help": "A simple pattern to match the instance names of the instances this rule is to be applied to."
}
},
"config": {
@@ -462,8 +433,8 @@
"ui:classNames": "dyncfg-grid dyncfg-grid-col-6 dyncfg-grid-col-span-1-6",
"database_lookup": {
"ui:classNames": "dyncfg-grid dyncfg-grid-col-6 dyncfg-grid-col-span-1-6",
- "ui:Collapsible": true,
- "ui:InitiallyExpanded": true,
+ "ui:collapsible": true,
+ "ui:initiallyExpanded": true,
"after": {
"ui:help": "The oldest timestamp of the time-series data to be included in the query. Negative values define a duration in seconds in the past of 'To' (so, -60 means a minute ago from 'To').",
"ui:classNames": "dyncfg-grid-col-span-1-1"
@@ -523,8 +494,8 @@
"ui:help": "Options related to the actions this alert will take."
},
"delay": {
- "ui:Collapsible": true,
- "ui:InitiallyExpanded": false,
+ "ui:collapsible": true,
+ "ui:initiallyExpanded": false,
"ui:classNames": "dyncfg-grid dyncfg-grid-col-6 dyncfg-grid-col-span-1-6",
"up": {
"ui:classNames": "dyncfg-grid-col-span-1-2",
@@ -544,8 +515,8 @@
}
},
"repeat": {
- "ui:Collapsible": true,
- "ui:InitiallyExpanded": false,
+ "ui:collapsible": true,
+ "ui:initiallyExpanded": false,
"ui:classNames": "dyncfg-grid dyncfg-grid-col-6 dyncfg-grid-col-span-1-6",
"enabled": {
"ui:classNames": "dyncfg-grid-col-span-1-2"