mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmselect/promql: fill gaps with 0 in rate_over_sum
response when the last value before the selected time window isnt empty
This commit is contained in:
parent
f068ea74d0
commit
d9037b3970
1 changed files with 10 additions and 3 deletions
|
@ -516,6 +516,8 @@ func (rc *rollupConfig) doInternal(dstValues []float64, tsm *timeseriesMap, valu
|
|||
rfa.currTimestamp = tEnd
|
||||
if i > 0 {
|
||||
rfa.realPrevValue = values[i-1]
|
||||
} else {
|
||||
rfa.realPrevValue = nan
|
||||
}
|
||||
value := rc.Func(rfa)
|
||||
rfa.idx++
|
||||
|
@ -1093,16 +1095,20 @@ func rollupRateOverSum(rfa *rollupFuncArg) float64 {
|
|||
timestamps := rfa.timestamps
|
||||
prevTimestamp := rfa.prevTimestamp
|
||||
if math.IsNaN(rfa.prevValue) {
|
||||
if len(values) == 0 {
|
||||
if len(timestamps) == 0 {
|
||||
return nan
|
||||
}
|
||||
prevTimestamp = timestamps[0]
|
||||
values = values[1:]
|
||||
timestamps = timestamps[1:]
|
||||
}
|
||||
if len(values) == 0 {
|
||||
if len(timestamps) == 0 {
|
||||
if math.IsNaN(rfa.prevValue) {
|
||||
return nan
|
||||
}
|
||||
// Assume that the value didn't change since rfa.prevValue.
|
||||
return 0
|
||||
}
|
||||
sum := float64(0)
|
||||
for _, v := range values {
|
||||
sum += v
|
||||
|
@ -1235,6 +1241,7 @@ func rollupDeltaInternal(rfa *rollupFuncArg, canUseRealPrevValue bool) float64 {
|
|||
}
|
||||
} else {
|
||||
prevValue = values[0]
|
||||
values = values[1:]
|
||||
}
|
||||
}
|
||||
if len(values) == 0 {
|
||||
|
|
Loading…
Reference in a new issue