summaryrefslogtreecommitdiffstats
path: root/ml
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2022-01-26 18:05:15 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2022-01-26 18:05:42 +0000
commit112b5b91647c3dea45cc1c9bc364df526c8012f1 (patch)
tree450af925135ec664c4310a1eb28b69481094ee2a /ml
parentReleasing debian version 1.32.1-2. (diff)
downloadnetdata-112b5b91647c3dea45cc1c9bc364df526c8012f1.tar.xz
netdata-112b5b91647c3dea45cc1c9bc364df526c8012f1.zip
Merging upstream version 1.33.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ml')
-rw-r--r--ml/Config.cc14
-rw-r--r--ml/Config.h3
-rw-r--r--ml/Host.cc4
-rw-r--r--ml/kmeans/SamplesBuffer.h5
-rw-r--r--ml/ml-dummy.c5
-rw-r--r--ml/ml.cc14
-rw-r--r--ml/ml.h1
7 files changed, 35 insertions, 11 deletions
diff --git a/ml/Config.cc b/ml/Config.cc
index f48f9b39..df0a2825 100644
--- a/ml/Config.cc
+++ b/ml/Config.cc
@@ -47,12 +47,6 @@ void Config::readMLConfig(void) {
double ADWindowRateThreshold = config_get_float(ConfigSectionML, "window minimum anomaly rate", 0.25);
double ADDimensionRateThreshold = config_get_float(ConfigSectionML, "anomaly event min dimension rate threshold", 0.05);
- std::string HostsToSkip = config_get(ConfigSectionML, "hosts to skip from training", "!*");
- std::string ChartsToSkip = config_get(ConfigSectionML, "charts to skip from training",
- "!system.* !cpu.* !mem.* !disk.* !disk_* "
- "!ip.* !ipv4.* !ipv6.* !net.* !net_* !netfilter.* "
- "!services.* !apps.* !groups.* !user.* !ebpf.* !netdata.* *");
-
std::stringstream SS;
SS << netdata_configured_cache_dir << "/anomaly-detection.db";
Cfg.AnomalyDBPath = SS.str();
@@ -123,6 +117,12 @@ void Config::readMLConfig(void) {
Cfg.ADWindowRateThreshold = ADWindowRateThreshold;
Cfg.ADDimensionRateThreshold = ADDimensionRateThreshold;
- Cfg.SP_HostsToSkip = simple_pattern_create(HostsToSkip.c_str(), NULL, SIMPLE_PATTERN_EXACT);
+ Cfg.HostsToSkip = config_get(ConfigSectionML, "hosts to skip from training", "!*");
+ Cfg.SP_HostsToSkip = simple_pattern_create(Cfg.HostsToSkip.c_str(), NULL, SIMPLE_PATTERN_EXACT);
+
+ Cfg.ChartsToSkip = config_get(ConfigSectionML, "charts to skip from training",
+ "!system.* !cpu.* !mem.* !disk.* !disk_* "
+ "!ip.* !ipv4.* !ipv6.* !net.* !net_* !netfilter.* "
+ "!services.* !apps.* !groups.* !user.* !ebpf.* !netdata.* *");
Cfg.SP_ChartsToSkip = simple_pattern_create(ChartsToSkip.c_str(), NULL, SIMPLE_PATTERN_EXACT);
}
diff --git a/ml/Config.h b/ml/Config.h
index f29bae3a..58ecce53 100644
--- a/ml/Config.h
+++ b/ml/Config.h
@@ -30,7 +30,10 @@ public:
double ADWindowRateThreshold;
double ADDimensionRateThreshold;
+ std::string HostsToSkip;
SIMPLE_PATTERN *SP_HostsToSkip;
+
+ std::string ChartsToSkip;
SIMPLE_PATTERN *SP_ChartsToSkip;
std::string AnomalyDBPath;
diff --git a/ml/Host.cc b/ml/Host.cc
index d26ff2ae..b632710a 100644
--- a/ml/Host.cc
+++ b/ml/Host.cc
@@ -282,6 +282,9 @@ void RrdHost::getConfigAsJson(nlohmann::json &Json) const {
Json["idle-window-size"] = Cfg.ADIdleWindowSize;
Json["window-rate-threshold"] = Cfg.ADWindowRateThreshold;
Json["dimension-rate-threshold"] = Cfg.ADDimensionRateThreshold;
+
+ Json["hosts-to-skip"] = Cfg.HostsToSkip;
+ Json["charts-to-skip"] = Cfg.ChartsToSkip;
}
std::pair<Dimension *, Duration<double>>
@@ -441,6 +444,7 @@ void DetectableHost::detect() {
}
void DetectableHost::getDetectionInfoAsJson(nlohmann::json &Json) const {
+ Json["version"] = 1;
Json["anomalous-dimensions"] = NumAnomalousDimensions;
Json["normal-dimensions"] = NumNormalDimensions;
Json["total-dimensions"] = NumAnomalousDimensions + NumNormalDimensions;
diff --git a/ml/kmeans/SamplesBuffer.h b/ml/kmeans/SamplesBuffer.h
index fccd216d..5c3cb1a9 100644
--- a/ml/kmeans/SamplesBuffer.h
+++ b/ml/kmeans/SamplesBuffer.h
@@ -20,8 +20,9 @@ public:
Sample(CalculatedNumber *Buf, size_t N) : CNs(Buf), NumDims(N) {}
void initDSample(DSample &DS) const {
- for (size_t Idx = 0; Idx != NumDims; Idx++)
- DS(Idx) = CNs[Idx];
+ for (size_t Idx = 0; Idx != NumDims; Idx++) {
+ DS(Idx) = std::abs(CNs[Idx]);
+ }
}
void add(const Sample &RHS) const {
diff --git a/ml/ml-dummy.c b/ml/ml-dummy.c
index 795b80c3..222f0b0f 100644
--- a/ml/ml-dummy.c
+++ b/ml/ml-dummy.c
@@ -10,7 +10,10 @@ void ml_new_host(RRDHOST *RH) { (void) RH; }
void ml_delete_host(RRDHOST *RH) { (void) RH; }
-char *ml_get_host_info(RRDHOST *RH) { (void) RH; }
+char *ml_get_host_info(RRDHOST *RH) {
+ (void) RH;
+ return NULL;
+}
void ml_new_dimension(RRDDIM *RD) { (void) RD; }
diff --git a/ml/ml.cc b/ml/ml.cc
index 857d23d3..cfda3d28 100644
--- a/ml/ml.cc
+++ b/ml/ml.cc
@@ -75,7 +75,6 @@ char *ml_get_host_info(RRDHOST *RH) {
if (RH && RH->ml_host) {
Host *H = static_cast<Host *>(RH->ml_host);
H->getConfigAsJson(ConfigJson);
- H->getDetectionInfoAsJson(ConfigJson);
} else {
ConfigJson["enabled"] = false;
}
@@ -83,6 +82,19 @@ char *ml_get_host_info(RRDHOST *RH) {
return strdup(ConfigJson.dump(2, '\t').c_str());
}
+char *ml_get_host_runtime_info(RRDHOST *RH) {
+ nlohmann::json ConfigJson;
+
+ if (RH && RH->ml_host) {
+ Host *H = static_cast<Host *>(RH->ml_host);
+ H->getDetectionInfoAsJson(ConfigJson);
+ } else {
+ return nullptr;
+ }
+
+ return strdup(ConfigJson.dump(1, '\t').c_str());
+}
+
bool ml_is_anomalous(RRDDIM *RD, double Value, bool Exists) {
Dimension *D = static_cast<Dimension *>(RD->state->ml_dimension);
if (!D)
diff --git a/ml/ml.h b/ml/ml.h
index 96448453..783bfabb 100644
--- a/ml/ml.h
+++ b/ml/ml.h
@@ -18,6 +18,7 @@ void ml_new_host(RRDHOST *RH);
void ml_delete_host(RRDHOST *RH);
char *ml_get_host_info(RRDHOST *RH);
+char *ml_get_host_runtime_info(RRDHOST *RH);
void ml_new_dimension(RRDDIM *RD);
void ml_delete_dimension(RRDDIM *RD);