mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-01-30 15:22:07 +00:00
app/vmselect/promql: properly handle precision errors in rollup functions
changes(), increases_over_time() and resets() shouldn't take into account value changes, which may occur because of precision errors. The maximum guaranteed precision for raw samples stored in VictoriaMetrics is 12 decimal digits. So do not count relative changes for values if they are smaller than 1e-12 comparing to the value. Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/767
This commit is contained in:
parent
d5b9b56ae4
commit
726751a311
2 changed files with 17 additions and 0 deletions
|
@ -1893,6 +1893,10 @@ func rollupChangesPrometheus(rfa *rollupFuncArg) float64 {
|
|||
n := 0
|
||||
for _, v := range values[1:] {
|
||||
if v != prevValue {
|
||||
if math.Abs(v-prevValue) < 1e-12*math.Abs(v) {
|
||||
// This may be precision error. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/767#issuecomment-1650932203
|
||||
continue
|
||||
}
|
||||
n++
|
||||
prevValue = v
|
||||
}
|
||||
|
@ -1916,6 +1920,10 @@ func rollupChanges(rfa *rollupFuncArg) float64 {
|
|||
}
|
||||
for _, v := range values {
|
||||
if v != prevValue {
|
||||
if math.Abs(v-prevValue) < 1e-12*math.Abs(v) {
|
||||
// This may be precision error. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/767#issuecomment-1650932203
|
||||
continue
|
||||
}
|
||||
n++
|
||||
prevValue = v
|
||||
}
|
||||
|
@ -1944,6 +1952,10 @@ func rollupIncreases(rfa *rollupFuncArg) float64 {
|
|||
n := 0
|
||||
for _, v := range values {
|
||||
if v > prevValue {
|
||||
if math.Abs(v-prevValue) < 1e-12*math.Abs(v) {
|
||||
// This may be precision error. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/767#issuecomment-1650932203
|
||||
continue
|
||||
}
|
||||
n++
|
||||
}
|
||||
prevValue = v
|
||||
|
@ -1975,6 +1987,10 @@ func rollupResets(rfa *rollupFuncArg) float64 {
|
|||
n := 0
|
||||
for _, v := range values {
|
||||
if v < prevValue {
|
||||
if math.Abs(v-prevValue) < 1e-12*math.Abs(v) {
|
||||
// This may be precision error. See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/767#issuecomment-1650932203
|
||||
continue
|
||||
}
|
||||
n++
|
||||
}
|
||||
prevValue = v
|
||||
|
|
|
@ -14,6 +14,7 @@ The following `tip` changes can be tested by building VictoriaMetrics components
|
|||
* SECURITY: upgrade Go builder from Go1.21.6 to Go1.21.7. See [the list of issues addressed in Go1.21.7](https://github.com/golang/go/issues?q=milestone%3AGo1.21.7+label%3ACherryPickApproved).
|
||||
|
||||
* BUGFIX: [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html): properly propagate [label filters](https://docs.victoriametrics.com/keyconcepts/#filtering) from multiple arguments passed to [aggregate functions](https://docs.victoriametrics.com/metricsql/#aggregate-functions). For example, `sum({job="foo"}, {job="bar"}) by (job) + a` was improperly optimized to `sum({job="foo"}, {job="bar"}) by (job) + a{job="foo"}` before being executed. This could lead to unexpected results. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/5604).
|
||||
* BUGFIX: [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html): properly handle precision errors when calculating [changes](https://docs.victoriametrics.com/metricsql/#changes), [changes_prometheus](https://docs.victoriametrics.com/metricsql/#changes_prometheus), [increases_over_time](https://docs.victoriametrics.com/metricsql/#increases_over_time) and [resets](https://docs.victoriametrics.com/metricsql/#resets) functions. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/767).
|
||||
|
||||
## [v1.93.11](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.93.11)
|
||||
|
||||
|
|
Loading…
Reference in a new issue