promql: fix increase_pure calculation for cases with stale series (#1381)

Due to staleness handling, increase_pure were using incorrect previous value
during calculation in cases where series disappears for period longer
than staleness period and then returns back. The fix suppose to account
for a real datapoint value before staleness takes place. The fix should
remove unexpected spikes while using `increase_pure` for staled series.
This commit is contained in:
Roman Khavronenko 2021-06-15 17:37:19 +03:00 committed by GitHub
parent 6a8369f0fc
commit fb4f758715
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1332,7 +1332,8 @@ func rollupIncreasePure(rfa *rollupFuncArg) float64 {
// There is no need in handling NaNs here, since they must be cleaned up // There is no need in handling NaNs here, since they must be cleaned up
// before calling rollup funcs. // before calling rollup funcs.
values := rfa.values values := rfa.values
prevValue := rfa.prevValue // restore to the real value because of potential staleness reset
prevValue := rfa.realPrevValue
if math.IsNaN(prevValue) { if math.IsNaN(prevValue) {
if len(values) == 0 { if len(values) == 0 {
return nan return nan