summaryrefslogtreecommitdiffstats
path: root/src/ml/Config.cc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-11-09 08:36:07 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-11-25 11:21:20 +0000
commiteae52fdaa9298e00f14b0b6256400d200db9c373 (patch)
treea3040a19bd024295ded05370853647bab9d7c225 /src/ml/Config.cc
parentAdding upstream version 1.47.5. (diff)
downloadnetdata-eae52fdaa9298e00f14b0b6256400d200db9c373.tar.xz
netdata-eae52fdaa9298e00f14b0b6256400d200db9c373.zip
Adding upstream version 2.0.3.upstream/2.0.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/ml/Config.cc')
-rw-r--r--src/ml/Config.cc27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/ml/Config.cc b/src/ml/Config.cc
index c6a750995..ccca7723b 100644
--- a/src/ml/Config.cc
+++ b/src/ml/Config.cc
@@ -19,7 +19,7 @@ static T clamp(const T& Value, const T& Min, const T& Max) {
void ml_config_load(ml_config_t *cfg) {
const char *config_section_ml = CONFIG_SECTION_ML;
- bool enable_anomaly_detection = config_get_boolean(config_section_ml, "enabled", true);
+ int enable_anomaly_detection = config_get_boolean_ondemand(config_section_ml, "enabled", CONFIG_BOOLEAN_AUTO);
/*
* Read values
@@ -27,29 +27,32 @@ void ml_config_load(ml_config_t *cfg) {
unsigned max_train_samples = config_get_number(config_section_ml, "maximum num samples to train", 6 * 3600);
unsigned min_train_samples = config_get_number(config_section_ml, "minimum num samples to train", 1 * 900);
- unsigned train_every = config_get_number(config_section_ml, "train every", 3 * 3600);
+ unsigned train_every = config_get_duration_seconds(config_section_ml, "train every", 3 * 3600);
unsigned num_models_to_use = config_get_number(config_section_ml, "number of models per dimension", 18);
- unsigned delete_models_older_than = config_get_number(config_section_ml, "delete models older than", 60 * 60 * 24 * 7);
+ unsigned delete_models_older_than = config_get_duration_seconds(config_section_ml, "delete models older than", 60 * 60 * 24 * 7);
unsigned diff_n = config_get_number(config_section_ml, "num samples to diff", 1);
unsigned smooth_n = config_get_number(config_section_ml, "num samples to smooth", 3);
unsigned lag_n = config_get_number(config_section_ml, "num samples to lag", 5);
- double random_sampling_ratio = config_get_float(config_section_ml, "random sampling ratio", 1.0 / 5.0 /* default lag_n */);
+ double random_sampling_ratio = config_get_double(config_section_ml, "random sampling ratio", 1.0 / 5.0 /* default lag_n */);
unsigned max_kmeans_iters = config_get_number(config_section_ml, "maximum number of k-means iterations", 1000);
- double dimension_anomaly_rate_threshold = config_get_float(config_section_ml, "dimension anomaly score threshold", 0.99);
+ double dimension_anomaly_rate_threshold = config_get_double(config_section_ml, "dimension anomaly score threshold", 0.99);
- double host_anomaly_rate_threshold = config_get_float(config_section_ml, "host anomaly rate threshold", 1.0);
+ double host_anomaly_rate_threshold = config_get_double(config_section_ml, "host anomaly rate threshold", 1.0);
std::string anomaly_detection_grouping_method = config_get(config_section_ml, "anomaly detection grouping method", "average");
- time_t anomaly_detection_query_duration = config_get_number(config_section_ml, "anomaly detection grouping duration", 5 * 60);
+ time_t anomaly_detection_query_duration = config_get_duration_seconds(config_section_ml, "anomaly detection grouping duration", 5 * 60);
size_t num_training_threads = config_get_number(config_section_ml, "num training threads", 4);
size_t flush_models_batch_size = config_get_number(config_section_ml, "flush models batch size", 128);
- size_t suppression_window = config_get_number(config_section_ml, "dimension anomaly rate suppression window", 900);
- size_t suppression_threshold = config_get_number(config_section_ml, "dimension anomaly rate suppression threshold", suppression_window / 2);
+ size_t suppression_window =
+ config_get_duration_seconds(config_section_ml, "dimension anomaly rate suppression window", 900);
+
+ size_t suppression_threshold =
+ config_get_number(config_section_ml, "dimension anomaly rate suppression threshold", suppression_window / 2);
bool enable_statistics_charts = config_get_boolean(config_section_ml, "enable statistics charts", false);
@@ -136,4 +139,10 @@ void ml_config_load(ml_config_t *cfg) {
cfg->suppression_threshold = suppression_threshold;
cfg->enable_statistics_charts = enable_statistics_charts;
+
+ if (cfg->enable_anomaly_detection == CONFIG_BOOLEAN_AUTO && default_rrd_memory_mode != RRD_MEMORY_MODE_DBENGINE) {
+ Cfg.enable_anomaly_detection = 0;
+ config_set_boolean(config_section_ml, "enabled", CONFIG_BOOLEAN_NO);
+ return;
+ }
}