diff options
author | thiagoftsm <thiagoftsm@gmail.com> | 2021-04-28 23:32:43 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-28 23:32:43 +0000 |
commit | e1b409efd10491b281e39f5637a08fb7b542866d (patch) | |
tree | bf3484d717d1410fd526250a2c7847277839b456 /health | |
parent | 6ec39d20ccb48f90b8e801dd91f51ab9141b941a (diff) |
Add `charts` to templates (#11054)
Add new entities to Netdata templates.
Diffstat (limited to 'health')
-rw-r--r-- | health/REFERENCE.md | 14 | ||||
-rw-r--r-- | health/health_config.c | 10 |
2 files changed, 24 insertions, 0 deletions
diff --git a/health/REFERENCE.md b/health/REFERENCE.md index 6621c5bd6c..efcd9fe013 100644 --- a/health/REFERENCE.md +++ b/health/REFERENCE.md @@ -62,6 +62,7 @@ Netdata parses the following lines. Beneath the table is an in-depth explanation | [`hosts`](#alarm-line-hosts) | no | Which hostnames will run this alarm. | | [`plugin`](#alarm-line-plugin) | no | Restrict an alarm or template to only a certain plugin. | | [`module`](#alarm-line-module) | no | Restrict an alarm or template to only a certain module. | +| [`charts`](#alarm-line-charts) | no | Restrict an alarm or template to only certain charts. | | [`families`](#alarm-line-families) | no | Restrict a template to only certain families. | | [`lookup`](#alarm-line-lookup) | yes | The database lookup to find and process metrics for the chart specified through `on`. | | [`calc`](#alarm-line-calc) | yes (see above) | A calculation to apply to the value found via `lookup` or another variable. | @@ -177,6 +178,19 @@ plugin: python.d.plugin module: isc_dhcpd ``` +#### Alarm line `charts` + +The `charts` line filters which chart this alarm should apply to. It is only available on entities using the +[`template`](#alarm-line-alarm-or-template) line. +The value is a space-separated list of [simple patterns](/libnetdata/simple_pattern/README.md). For +example, a template that applies to `disk.svctm` (Average Service Time) context, but excludes the disk `sdb` from alarms: + +```yaml +template: disk_svctm_alarm + on: disk.svctm + charts: !*sdb* * +``` + #### Alarm line `families` The `families` line, used only alongside templates, filters which families within the context this alarm should apply diff --git a/health/health_config.c b/health/health_config.c index 6094c91fd1..756023715e 100644 --- a/health/health_config.c +++ b/health/health_config.c @@ -12,6 +12,7 @@ #define HEALTH_FAMILIES_KEY "families" #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" @@ -493,6 +494,7 @@ static int health_readfile(const char *filename, void *data) { hash_families = 0, hash_plugin = 0, hash_module = 0, + hash_charts = 0, hash_calc = 0, hash_green = 0, hash_red = 0, @@ -523,6 +525,7 @@ static int health_readfile(const char *filename, void *data) { hash_families = simple_uhash(HEALTH_FAMILIES_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); @@ -945,6 +948,13 @@ static int health_readfile(const char *filename, void *data) { rt->module_match = strdupz(value); rt->module_pattern = simple_pattern_create(rt->module_match, NULL, SIMPLE_PATTERN_EXACT); } + else if(hash == hash_charts && !strcasecmp(key, HEALTH_CHARTS_KEY)) { + freez(rt->charts_match); + simple_pattern_free(rt->charts_pattern); + + rt->charts_match = strdupz(value); + rt->charts_pattern = simple_pattern_create(rt->charts_match, NULL, SIMPLE_PATTERN_EXACT); + } else if(hash == hash_lookup && !strcasecmp(key, HEALTH_LOOKUP_KEY)) { health_parse_db_lookup(line, filename, value, &rt->group, &rt->after, &rt->before, &rt->update_every, &rt->options, &rt->dimensions, &rt->foreachdim); |