summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorvkalintiris <vasilis@netdata.cloud>2022-02-24 10:57:30 +0200
committerGitHub <noreply@github.com>2022-02-24 10:57:30 +0200
commit69ea17d6ec534e1ed796a92fd042bd76a3ca9215 (patch)
tree4345e3405b2ac1e37a9be1615d6dad799e15327d /web
parent8756eb80c77caf411f7fae605d3f1bb03dd60b76 (diff)
Track anomaly rates with DBEngine. (#12083)
* Track anomaly rates with DBEngine. This commit adds support for tracking anomaly rates with DBEngine. We do so by creating a single chart with id "anomaly_detection.anomaly_rates" for each trainable/predictable host, which is responsible for tracking the anomaly rate of each dimension that we train/predict for that host. The rrdset->state->is_ar_chart boolean flag is set to true only for anomaly rates charts. We use this flag to: - Disable exposing the anomaly rates charts through the functionality in backends/, exporting/ and streaming/. - Skip generation of configuration options for the name, algorithm, multiplier, divisor of each dimension in an anomaly rates chart. - Skip the creation of health variables for anomaly rates dimensions. - Skip the chart/dim queue of ACLK. - Post-process the RRDR result of an anomaly rates chart, so that we can return a sorted, trimmed number of anomalous dimensions. In a child/parent configuration where both the child and the parent run ML for the child, we want to be able to stream the rest of the ML-related charts to the parent. To be able to do this without any chart name collisions, the charts are now created on localhost and their IDs and titles have the node's machine_guid and hostname as a suffix, respectively. * Fix exporting_engine tests. * Restore default ML configuration. The reverted changes where meant for local testing only. This commit restores the default values that we want to have when someone runs anomaly detection on their node. * Set context for anomaly_detection.* charts. * Check for anomaly rates chart only with a valid pointer. * Remove duplicate code. * Use a more descriptive name for id/title pair variable
Diffstat (limited to 'web')
-rw-r--r--web/api/formatters/rrd2json.c4
-rw-r--r--web/api/formatters/rrd2json.h1
-rw-r--r--web/api/web_api_v1.c25
3 files changed, 21 insertions, 9 deletions
diff --git a/web/api/formatters/rrd2json.c b/web/api/formatters/rrd2json.c
index f27ee77c29..b9dd72084e 100644
--- a/web/api/formatters/rrd2json.c
+++ b/web/api/formatters/rrd2json.c
@@ -217,6 +217,7 @@ int rrdset2anything_api_v1(
, time_t *latest_timestamp
, struct context_param *context_param_list
, char *chart_label_key
+ , int max_anomaly_rates
) {
if (context_param_list && !(context_param_list->flags & CONTEXT_FLAGS_ARCHIVE))
@@ -228,6 +229,9 @@ int rrdset2anything_api_v1(
return HTTP_RESP_INTERNAL_SERVER_ERROR;
}
+ if (st && st->state->is_ar_chart)
+ ml_process_rrdr(r, max_anomaly_rates);
+
RRDDIM *temp_rd = context_param_list ? context_param_list->rd : NULL;
if(r->result_options & RRDR_RESULT_OPTION_RELATIVE)
diff --git a/web/api/formatters/rrd2json.h b/web/api/formatters/rrd2json.h
index 3dc5989735..c24547ca63 100644
--- a/web/api/formatters/rrd2json.h
+++ b/web/api/formatters/rrd2json.h
@@ -67,6 +67,7 @@ extern int rrdset2anything_api_v1(
, time_t *latest_timestamp
, struct context_param *context_param_list
, char *chart_label_key
+ , int max_anomaly_rates
);
extern int rrdset2value_api_v1(
diff --git a/web/api/web_api_v1.c b/web/api/web_api_v1.c
index 6361f9970b..2cfd69dc83 100644
--- a/web/api/web_api_v1.c
+++ b/web/api/web_api_v1.c
@@ -401,13 +401,14 @@ inline int web_client_api_request_v1_data(RRDHOST *host, struct web_client *w, c
time_t last_timestamp_in_data = 0, google_timestamp = 0;
- char *chart = NULL
- , *before_str = NULL
- , *after_str = NULL
- , *group_time_str = NULL
- , *points_str = NULL
- , *context = NULL
- , *chart_label_key = NULL;
+ char *chart = NULL;
+ char *before_str = NULL;
+ char *after_str = NULL;
+ char *group_time_str = NULL;
+ char *points_str = NULL;
+ char *max_anomaly_rates_str = NULL;
+ char *context = NULL;
+ char *chart_label_key = NULL;
int group = RRDR_GROUPING_AVERAGE;
uint32_t format = DATASOURCE_JSON;
@@ -484,6 +485,9 @@ inline int web_client_api_request_v1_data(RRDHOST *host, struct web_client *w, c
outFileName = tqx_value;
}
}
+ else if(!strcmp(name, "max_anomaly_rates")) {
+ max_anomaly_rates_str = value;
+ }
}
// validate the google parameters given
@@ -564,6 +568,7 @@ inline int web_client_api_request_v1_data(RRDHOST *host, struct web_client *w, c
long long after = (after_str && *after_str) ?str2l(after_str):-600;
int points = (points_str && *points_str)?str2i(points_str):0;
long group_time = (group_time_str && *group_time_str)?str2l(group_time_str):0;
+ int max_anomaly_rates = (max_anomaly_rates_str && *max_anomaly_rates_str) ? str2i(max_anomaly_rates_str) : 0;
debug(D_WEB_CLIENT, "%llu: API command 'data' for chart '%s', dimensions '%s', after '%lld', before '%lld', points '%d', group '%d', format '%u', options '0x%08x'"
, w->id
@@ -606,8 +611,10 @@ inline int web_client_api_request_v1_data(RRDHOST *host, struct web_client *w, c
buffer_strcat(w->response.data, "(");
}
- ret = rrdset2anything_api_v1(st, w->response.data, dimensions, format, points, after, before, group, group_time
- , options, &last_timestamp_in_data, context_param_list, chart_label_key);
+ ret = rrdset2anything_api_v1(st, w->response.data, dimensions, format,
+ points, after, before, group, group_time,
+ options, &last_timestamp_in_data, context_param_list,
+ chart_label_key, max_anomaly_rates);
free_context_param_list(&context_param_list);