mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 00:13:30 +01: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
@ -516,6 +516,8 @@ func (rc *rollupConfig) doInternal(dstValues []float64, tsm *timeseriesMap, valu
|
|||||||
rfa.currTimestamp = tEnd
|
rfa.currTimestamp = tEnd
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
rfa.realPrevValue = values[i-1]
|
rfa.realPrevValue = values[i-1]
|
||||||
|
} else {
|
||||||
|
rfa.realPrevValue = nan
|
||||||
}
|
}
|
||||||
value := rc.Func(rfa)
|
value := rc.Func(rfa)
|
||||||
rfa.idx++
|
rfa.idx++
|
||||||
@ -1093,16 +1095,20 @@ func rollupRateOverSum(rfa *rollupFuncArg) float64 {
|
|||||||
timestamps := rfa.timestamps
|
timestamps := rfa.timestamps
|
||||||
prevTimestamp := rfa.prevTimestamp
|
prevTimestamp := rfa.prevTimestamp
|
||||||
if math.IsNaN(rfa.prevValue) {
|
if math.IsNaN(rfa.prevValue) {
|
||||||
if len(values) == 0 {
|
if len(timestamps) == 0 {
|
||||||
return nan
|
return nan
|
||||||
}
|
}
|
||||||
prevTimestamp = timestamps[0]
|
prevTimestamp = timestamps[0]
|
||||||
values = values[1:]
|
values = values[1:]
|
||||||
timestamps = timestamps[1:]
|
timestamps = timestamps[1:]
|
||||||
}
|
}
|
||||||
if len(values) == 0 {
|
if len(timestamps) == 0 {
|
||||||
|
if math.IsNaN(rfa.prevValue) {
|
||||||
return nan
|
return nan
|
||||||
}
|
}
|
||||||
|
// Assume that the value didn't change since rfa.prevValue.
|
||||||
|
return 0
|
||||||
|
}
|
||||||
sum := float64(0)
|
sum := float64(0)
|
||||||
for _, v := range values {
|
for _, v := range values {
|
||||||
sum += v
|
sum += v
|
||||||
@ -1235,6 +1241,7 @@ func rollupDeltaInternal(rfa *rollupFuncArg, canUseRealPrevValue bool) float64 {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
prevValue = values[0]
|
prevValue = values[0]
|
||||||
|
values = values[1:]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(values) == 0 {
|
if len(values) == 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user