From def513355e418480892271d58522490a5146d80e Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 2 Dec 2020 13:11:32 +0200 Subject: [PATCH] app/vmselect/promql: do not return `0` value from `sum_over_time(m[d])` when there are no samples on the given `d` window. This aligns the behaviour of `sum_over_time()` with other `_over_time()` functions and with Prometheus behavior. --- app/vmselect/promql/rollup.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/vmselect/promql/rollup.go b/app/vmselect/promql/rollup.go index c711f04ad8..2685f72ca7 100644 --- a/app/vmselect/promql/rollup.go +++ b/app/vmselect/promql/rollup.go @@ -1142,10 +1142,10 @@ func rollupSum(rfa *rollupFuncArg) float64 { // before calling rollup funcs. values := rfa.values if len(values) == 0 { - if math.IsNaN(rfa.prevValue) { - return nan - } - return 0 + // Do not take into account rfa.prevValue, since it may lead + // to inconsistent results comparing to Prometheus on broken time series + // with irregular data points. + return nan } var sum float64 for _, v := range values {