mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 08:23:34 +01:00
app/vmselect/promql: return expected results from increase()
over the beginning of time series, which start from big value
Examples for such counters: OS-level counters for network or cpu stats.
This commit is contained in:
parent
11c03328ae
commit
b28c9a3944
@ -1157,10 +1157,18 @@ func rollupDeltaInternal(rfa *rollupFuncArg, canUseRealPrevValue bool) float64 {
|
|||||||
if len(values) == 0 {
|
if len(values) == 0 {
|
||||||
return nan
|
return nan
|
||||||
}
|
}
|
||||||
// Assume that the previous non-existing value was 0.
|
// Assume that the previous non-existing value was 0
|
||||||
prevValue = 0
|
// only if the first value is quite small.
|
||||||
if canUseRealPrevValue && !math.IsNaN(rfa.prevValue) {
|
// This should prevent from improper increase() results for os-level counters
|
||||||
prevValue = rfa.prevValue
|
// such as cpu time or bytes sent over the network interface.
|
||||||
|
// These counters may start long ago before the first value appears in the db.
|
||||||
|
if values[0] < 1e6 {
|
||||||
|
prevValue = 0
|
||||||
|
if canUseRealPrevValue && !math.IsNaN(rfa.realPrevValue) {
|
||||||
|
prevValue = rfa.realPrevValue
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
prevValue = values[0]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(values) == 0 {
|
if len(values) == 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user