diff options
-rw-r--r-- | ml/Dimension.h | 10 | ||||
-rw-r--r-- | ml/Host.cc | 13 | ||||
-rw-r--r-- | ml/Host.h | 1 |
3 files changed, 22 insertions, 2 deletions
diff --git a/ml/Dimension.h b/ml/Dimension.h index b2af323a4b..c29df781a4 100644 --- a/ml/Dimension.h +++ b/ml/Dimension.h @@ -30,6 +30,16 @@ public: return SS.str(); } + bool isActive() const { + if (rrdset_flag_check(RD->rrdset, RRDSET_FLAG_OBSOLETE)) + return false; + + if (rrddim_flag_check(RD, RRDDIM_FLAG_OBSOLETE)) + return false; + + return true; + } + void setAnomalyRateRD(RRDDIM *ARRD) { AnomalyRateRD = ARRD; } RRDDIM *getAnomalyRateRD() const { return AnomalyRateRD; } diff --git a/ml/Host.cc b/ml/Host.cc index 4f64bf694e..f8cba9d64e 100644 --- a/ml/Host.cc +++ b/ml/Host.cc @@ -413,6 +413,7 @@ void DetectableHost::detectOnce() { size_t NumAnomalousDimensions = 0; size_t NumNormalDimensions = 0; size_t NumTrainedDimensions = 0; + size_t NumActiveDimensions = 0; bool CollectAnomalyRates = (++AnomalyRateTimer == Cfg.DBEngineAnomalyRateEvery); if (CollectAnomalyRates) @@ -428,6 +429,13 @@ void DetectableHost::detectOnce() { Dimension *D = DP.second; + if (!D->isActive()) { + D->updateAnomalyBitCounter(AnomalyRateRS, AnomalyRateTimer, false); + continue; + } + + NumActiveDimensions++; + auto P = D->detect(WindowLength, ResetBitCounter); bool IsAnomalous = P.first; double AnomalyScore = P.second; @@ -444,11 +452,11 @@ void DetectableHost::detectOnce() { } if (NumAnomalousDimensions) - WindowAnomalyRate = static_cast<double>(NumAnomalousDimensions) / DimensionsMap.size(); + WindowAnomalyRate = static_cast<double>(NumAnomalousDimensions) / NumActiveDimensions; else WindowAnomalyRate = 0.0; - NumNormalDimensions = DimensionsMap.size() - NumAnomalousDimensions; + NumNormalDimensions = NumActiveDimensions - NumAnomalousDimensions; } if (CollectAnomalyRates) { @@ -460,6 +468,7 @@ void DetectableHost::detectOnce() { this->NumAnomalousDimensions = NumAnomalousDimensions; this->NumNormalDimensions = NumNormalDimensions; this->NumTrainedDimensions = NumTrainedDimensions; + this->NumActiveDimensions = NumActiveDimensions; worker_is_busy(WORKER_JOB_UPDATE_CHARTS); updateDimensionsChart(getRH(), NumTrainedDimensions, NumNormalDimensions, NumAnomalousDimensions); @@ -127,6 +127,7 @@ private: size_t NumAnomalousDimensions{0}; size_t NumNormalDimensions{0}; size_t NumTrainedDimensions{0}; + size_t NumActiveDimensions{0}; unsigned AnomalyRateTimer{0}; |