From b53e768b75ddc0cacd19d908be068d1f57306feb Mon Sep 17 00:00:00 2001 From: Mahendra Paipuri Date: Sat, 6 Apr 2024 19:04:42 +0200 Subject: [PATCH] fix: Check for negative values in agg metrics * If agg metrics is negative, return 0 Signed-off-by: Mahendra Paipuri --- pkg/api/updater/tsdb.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/api/updater/tsdb.go b/pkg/api/updater/tsdb.go index b0387251..70d6accf 100644 --- a/pkg/api/updater/tsdb.go +++ b/pkg/api/updater/tsdb.go @@ -394,9 +394,9 @@ func (t *tsdbUpdater) deleteTimeSeries(startTime time.Time, endTime time.Time, u } // sanitizeValue verifies if value is either NaN/Inf/-Inf. -// If value is any of these, zero will be returned +// If value is any of these, zero will be returned. Returns 0 if value is negative func sanitizeValue(val float64) models.JSONFloat { - if math.IsNaN(val) || math.IsInf(val, 0) { + if math.IsNaN(val) || math.IsInf(val, 0) || val < 0 { return models.JSONFloat(0) } return models.JSONFloat(val)