@cryptotaxi247 / netdata-1 / commits / d36896ed0

Treat dimensions as normal when we don't have enough/valid data. (#13005)

Ideally, we'd log such cases but this is not currently feasible because we have to process thousands of dimensions per second.

vkalintiris committed May 31, 2022 at 13:31 UTC d36896ed06478dda312567a8f987e3802fe14c22
1 file changed +6 -2
ml/Dimension.cc
+6 -2
@@ -161,8 +161,10 @@ void PredictableDimension::addValue(CalculatedNumber Value, bool Exists) {
161
162 std::pair<MLResult, bool> PredictableDimension::predict() {
163 unsigned N = Cfg.DiffN + Cfg.SmoothN + Cfg.LagN;
164 - if (CNs.size() != N)
164 + if (CNs.size() != N) {
165 + AnomalyBit = false;
166 return { MLResult::MissingData, AnomalyBit };
167 + }
168
169 CalculatedNumber *TmpCNs = new CalculatedNumber[N * (Cfg.LagN + 1)]();
170 std::memcpy(TmpCNs, CNs.data(), N * sizeof(CalculatedNumber));
@@ -172,8 +174,10 @@ std::pair<MLResult, bool> PredictableDimension::predict() {
174 AnomalyScore = computeAnomalyScore(SB);
175 delete[] TmpCNs;
176
175 - if (AnomalyScore == std::numeric_limits<CalculatedNumber>::quiet_NaN())
177 + if (AnomalyScore == std::numeric_limits<CalculatedNumber>::quiet_NaN()) {
178 + AnomalyBit = false;
179 return { MLResult::NaN, AnomalyBit };
180 + }
181
182 AnomalyBit = AnomalyScore >= (100 * Cfg.DimensionAnomalyScoreThreshold);
183 return { MLResult::Success, AnomalyBit };