diff options
author | vkalintiris <vasilis@netdata.cloud> | 2022-11-09 11:02:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-09 11:02:57 +0200 |
commit | 44a75ea996268466c38b596294677f3b80350103 (patch) | |
tree | 65cc6a32a03e38573232fd4523b913a9aaec9aec /ml | |
parent | 9d80f78817916fcf163b081e750dc0b13e8a5a7e (diff) |
Remove anomaly rates chart. (#13763)
Diffstat (limited to 'ml')
-rw-r--r-- | ml/Config.cc | 6 | ||||
-rw-r--r-- | ml/Dimension.cc | 10 | ||||
-rw-r--r-- | ml/Dimension.h | 18 | ||||
-rw-r--r-- | ml/Host.cc | 15 | ||||
-rw-r--r-- | ml/Host.h | 27 | ||||
-rw-r--r-- | ml/ml-dummy.c | 11 | ||||
-rw-r--r-- | ml/ml.cc | 43 | ||||
-rw-r--r-- | ml/ml.h | 4 |
8 files changed, 5 insertions, 129 deletions
diff --git a/ml/Config.cc b/ml/Config.cc index 63b570156a..eedd8c29fd 100644 --- a/ml/Config.cc +++ b/ml/Config.cc @@ -33,8 +33,6 @@ void Config::readMLConfig(void) { unsigned TrainEvery = config_get_number(ConfigSectionML, "train every", 1 * 3600); unsigned NumModelsToUse = config_get_number(ConfigSectionML, "number of models per dimension", 1 * 24); - unsigned DBEngineAnomalyRateEvery = config_get_number(ConfigSectionML, "dbengine anomaly rate every", 30); - unsigned DiffN = config_get_number(ConfigSectionML, "num samples to diff", 1); unsigned SmoothN = config_get_number(ConfigSectionML, "num samples to smooth", 3); unsigned LagN = config_get_number(ConfigSectionML, "num samples to lag", 5); @@ -57,8 +55,6 @@ void Config::readMLConfig(void) { TrainEvery = clamp<unsigned>(TrainEvery, 1 * 3600, 6 * 3600); NumModelsToUse = clamp<unsigned>(TrainEvery, 1, 7 * 24); - DBEngineAnomalyRateEvery = clamp(DBEngineAnomalyRateEvery, 1 * 30u, 15 * 60u); - DiffN = clamp(DiffN, 0u, 1u); SmoothN = clamp(SmoothN, 0u, 5u); LagN = clamp(LagN, 1u, 5u); @@ -93,8 +89,6 @@ void Config::readMLConfig(void) { Cfg.TrainEvery = TrainEvery; Cfg.NumModelsToUse = NumModelsToUse; - Cfg.DBEngineAnomalyRateEvery = DBEngineAnomalyRateEvery; - Cfg.DiffN = DiffN; Cfg.SmoothN = SmoothN; Cfg.LagN = LagN; diff --git a/ml/Dimension.cc b/ml/Dimension.cc index 39e74a065d..bf34abb72f 100644 --- a/ml/Dimension.cc +++ b/ml/Dimension.cc @@ -167,16 +167,6 @@ bool Dimension::predict(CalculatedNumber Value, bool Exists) { return true; } -void Dimension::updateAnomalyBitCounter(RRDSET *RS, unsigned Elapsed, bool IsAnomalous) { - AnomalyBitCounter += IsAnomalous; - - if (Elapsed == Cfg.DBEngineAnomalyRateEvery) { - double AR = static_cast<double>(AnomalyBitCounter) / Cfg.DBEngineAnomalyRateEvery; - rrddim_set_by_pointer(RS, getAnomalyRateRD(), AR * 1000); - AnomalyBitCounter = 0; - } -} - std::array<KMeans, 1> Dimension::getModels() { std::unique_lock<std::mutex> Lock(Mutex); return Models; diff --git a/ml/Dimension.h b/ml/Dimension.h index eb37f0755a..3ec56e0981 100644 --- a/ml/Dimension.h +++ b/ml/Dimension.h @@ -26,15 +26,13 @@ static inline std::string getMLDimensionID(RRDDIM *RD) { class Dimension { public: - Dimension(RRDDIM *RD, RRDSET *AnomalyRateRS) : + Dimension(RRDDIM *RD) : RD(RD), - AnomalyRateRD(rrddim_add(AnomalyRateRS, ml::getMLDimensionID(RD).c_str(), NULL, 1, 1000, RRD_ALGORITHM_ABSOLUTE)), LastTrainedAt(Seconds(0)), Trained(false), ConstantModel(false), AnomalyScore(0.0), - AnomalyBit(0), - AnomalyBitCounter(0) + AnomalyBit(0) { } RRDDIM *getRD() const { @@ -53,14 +51,6 @@ public: return Query(RD).oldestTime(); } - void setAnomalyRateRDName(const char *Name) const { - rrddim_reset_name(AnomalyRateRD->rrdset, AnomalyRateRD, Name); - } - - RRDDIM *getAnomalyRateRD() const { - return AnomalyRateRD; - } - bool isTrained() const { return Trained; } @@ -77,8 +67,6 @@ public: bool predict(CalculatedNumber Value, bool Exists); - void updateAnomalyBitCounter(RRDSET *RS, unsigned Elapsed, bool IsAnomalous); - std::pair<bool, double> detect(size_t WindowLength, bool Reset); std::array<KMeans, 1> getModels(); @@ -88,7 +76,6 @@ private: public: RRDDIM *RD; - RRDDIM *AnomalyRateRD; TimePoint LastTrainedAt; std::atomic<bool> Trained; @@ -96,7 +83,6 @@ public: CalculatedNumber AnomalyScore; std::atomic<bool> AnomalyBit; - unsigned AnomalyBitCounter; std::vector<CalculatedNumber> CNs; std::array<KMeans, 1> Models; diff --git a/ml/Host.cc b/ml/Host.cc index 0eb35fff0b..0261061454 100644 --- a/ml/Host.cc +++ b/ml/Host.cc @@ -161,10 +161,6 @@ void DetectableHost::detectOnce() { size_t NumTrainedDimensions = 0; size_t NumActiveDimensions = 0; - bool CollectAnomalyRates = (++AnomalyRateTimer == Cfg.DBEngineAnomalyRateEvery); - if (CollectAnomalyRates) - rrdset_next(AnomalyRateRS); - { std::lock_guard<std::mutex> Lock(Mutex); @@ -173,10 +169,8 @@ void DetectableHost::detectOnce() { Dimension *D = DP.second; - if (!D->isActive()) { - D->updateAnomalyBitCounter(AnomalyRateRS, AnomalyRateTimer, false); + if (!D->isActive()) continue; - } NumActiveDimensions++; NumTrainedDimensions += D->isTrained(); @@ -184,7 +178,6 @@ void DetectableHost::detectOnce() { bool IsAnomalous = D->isAnomalous(); if (IsAnomalous) NumAnomalousDimensions += 1; - D->updateAnomalyBitCounter(AnomalyRateRS, AnomalyRateTimer, IsAnomalous); } if (NumAnomalousDimensions) @@ -195,12 +188,6 @@ void DetectableHost::detectOnce() { NumNormalDimensions = NumActiveDimensions - NumAnomalousDimensions; } - if (CollectAnomalyRates) { - worker_is_busy(WORKER_JOB_UPDATE_ANOMALY_RATES); - AnomalyRateTimer = 0; - rrdset_done(AnomalyRateRS); - } - this->NumAnomalousDimensions = NumAnomalousDimensions; this->NumNormalDimensions = NumNormalDimensions; this->NumTrainedDimensions = NumTrainedDimensions; @@ -13,25 +13,7 @@ namespace ml { class RrdHost { public: - RrdHost(RRDHOST *RH) : RH(RH) { - AnomalyRateRS = rrdset_create( - RH, - "anomaly_detection", - "anomaly_rates", - NULL, // name - "anomaly_rates", - NULL, // ctx - "Average anomaly rate", - "anomaly rate", - "netdata", - "ml", - 39189, - Cfg.DBEngineAnomalyRateEvery, - RRDSET_TYPE_LINE - ); - - rrdset_flag_set(AnomalyRateRS, RRDSET_FLAG_HIDDEN); - } + RrdHost(RRDHOST *RH) : RH(RH) {}; RRDHOST *getRH() { return RH; } @@ -43,10 +25,6 @@ public: return S; } - RRDSET *getAnomalyRateRS() const { - return AnomalyRateRS; - } - void addDimension(Dimension *D); void removeDimension(Dimension *D); @@ -56,7 +34,6 @@ public: protected: RRDHOST *RH; - RRDSET *AnomalyRateRS; // Protect dimension and lock maps std::mutex Mutex; @@ -114,8 +91,6 @@ private: size_t NumNormalDimensions{0}; size_t NumTrainedDimensions{0}; size_t NumActiveDimensions{0}; - - unsigned AnomalyRateTimer{0}; }; using Host = DetectableHost; diff --git a/ml/ml-dummy.c b/ml/ml-dummy.c index 6c0dce6011..492dfe2fce 100644 --- a/ml/ml-dummy.c +++ b/ml/ml-dummy.c @@ -43,17 +43,6 @@ bool ml_is_anomalous(RRDDIM *RD, double Value, bool Exists) { return false; } -void ml_process_rrdr(RRDR *R, int MaxAnomalyRates) { - (void) R; - (void) MaxAnomalyRates; -} - -void ml_dimension_update_name(RRDSET *RS, RRDDIM *RD, const char *name) { - (void) RS; - (void) RD; - (void) name; -} - bool ml_streaming_enabled() { return false; } @@ -79,10 +79,7 @@ void ml_new_dimension(RRDDIM *RD) { if (simple_pattern_matches(Cfg.SP_ChartsToSkip, rrdset_name(RS))) return; - if (rrdset_is_ar_chart(RS)) - return; - - Dimension *D = new Dimension(RD, H->getAnomalyRateRS()); + Dimension *D = new Dimension(RD); RD->ml_dimension = static_cast<ml_dimension_t>(D); H->addDimension(D); } @@ -147,44 +144,6 @@ bool ml_is_anomalous(RRDDIM *RD, double Value, bool Exists) { return D->predict(Value, Exists); } -void ml_process_rrdr(RRDR *R, int MaxAnomalyRates) { - if (R->rows != 1) - return; - - if (MaxAnomalyRates < 1 || MaxAnomalyRates >= (int)R->d) - return; - - NETDATA_DOUBLE *CNs = R->v; - RRDR_DIMENSION_FLAGS *DimFlags = R->od; - - std::vector<std::pair<NETDATA_DOUBLE, int>> V; - - V.reserve(R->d); - for (int Idx = 0; Idx != (int)R->d; Idx++) - V.emplace_back(CNs[Idx], Idx); - - std::sort(V.rbegin(), V.rend()); - - for (int Idx = MaxAnomalyRates; Idx != (int)R->d; Idx++) { - int UnsortedIdx = V[Idx].second; - - int OldFlags = static_cast<int>(DimFlags[UnsortedIdx]); - int NewFlags = OldFlags | RRDR_DIMENSION_HIDDEN; - - DimFlags[UnsortedIdx] = static_cast<rrdr_dimension_flag>(NewFlags); - } -} - -void ml_dimension_update_name(RRDSET *RS, RRDDIM *RD, const char *Name) { - (void) RS; - - Dimension *D = static_cast<Dimension *>(RD->ml_dimension); - if (!D) - return; - - D->setAnomalyRateRDName(Name); -} - bool ml_streaming_enabled() { return Cfg.StreamADCharts; } @@ -35,10 +35,6 @@ void ml_delete_dimension(RRDDIM *RD); bool ml_is_anomalous(RRDDIM *RD, double value, bool exists); -void ml_process_rrdr(RRDR *R, int MaxAnomalyRates); - -void ml_dimension_update_name(RRDSET *RS, RRDDIM *RD, const char *name); - bool ml_streaming_enabled(); #define ML_ANOMALY_RATES_CHART_ID "anomaly_detection.anomaly_rates" |