mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-14 16:12:15 +01:00
app/vmselect/promql: follow-up for 79e1c6a6fc
- Document the fix at docs/CHANGELOG.md - Add tests with multiple adjancent zero buckets - Simplify the fix a bit Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/296 Updates https://github.com/VictoriaMetrics/VictoriaMetrics/pull/4021
This commit is contained in:
parent
680a661ec0
commit
54b9537a76
@ -552,33 +552,32 @@ func vmrangeBucketsToLE(tss []*timeseries) []*timeseries {
|
||||
sort.Slice(xss, func(i, j int) bool { return xss[i].end < xss[j].end })
|
||||
xssNew := make([]x, 0, len(xss)+2)
|
||||
var xsPrev x
|
||||
hasNonEmpty := false
|
||||
uniqTs := make(map[string]*timeseries, len(xss))
|
||||
for _, xs := range xss {
|
||||
ts := xs.ts
|
||||
if isZeroTS(ts) {
|
||||
xsPrev = xs
|
||||
// Skip buckets with zero values - they will be merged into a single bucket
|
||||
// when the next non-zero bucket appears.
|
||||
|
||||
if uniqTs[xs.endStr] == nil {
|
||||
uniqTs[xs.endStr] = xs.ts
|
||||
xssNew = append(xssNew, x{
|
||||
endStr: xs.endStr,
|
||||
end: xs.end,
|
||||
ts: copyTS(ts, xs.endStr),
|
||||
})
|
||||
}
|
||||
// Do not store xs in xsPrev in order to properly create `le` time series
|
||||
// for zero buckets.
|
||||
// See https://github.com/VictoriaMetrics/VictoriaMetrics/pull/4021
|
||||
continue
|
||||
}
|
||||
|
||||
hasNonEmpty = true
|
||||
if xs.start != xsPrev.end && uniqTs[xs.startStr] == nil {
|
||||
uniqTs[xs.startStr] = xs.ts
|
||||
xssNew = append(xssNew, x{
|
||||
endStr: xs.startStr,
|
||||
end: xs.start,
|
||||
ts: copyTS(ts, xs.startStr),
|
||||
})
|
||||
if xs.start != xsPrev.end {
|
||||
// There is a gap between the previous bucket and the current bucket
|
||||
// or the previous bucket is skipped because it was zero.
|
||||
// Fill it with a time series with le=xs.start.
|
||||
if uniqTs[xs.startStr] == nil {
|
||||
uniqTs[xs.startStr] = xs.ts
|
||||
xssNew = append(xssNew, x{
|
||||
endStr: xs.startStr,
|
||||
end: xs.start,
|
||||
ts: copyTS(ts, xs.startStr),
|
||||
})
|
||||
}
|
||||
}
|
||||
// Convert the current time series to a time series with le=xs.end
|
||||
ts.MetricName.AddTag("le", xs.endStr)
|
||||
prevTs := uniqTs[xs.endStr]
|
||||
if prevTs != nil {
|
||||
@ -590,13 +589,7 @@ func vmrangeBucketsToLE(tss []*timeseries) []*timeseries {
|
||||
}
|
||||
xsPrev = xs
|
||||
}
|
||||
|
||||
if !hasNonEmpty {
|
||||
xssNew = []x{}
|
||||
continue
|
||||
}
|
||||
|
||||
if !math.IsInf(xsPrev.end, 1) && !isZeroTS(xsPrev.ts) {
|
||||
if xsPrev.ts != nil && !math.IsInf(xsPrev.end, 1) && !isZeroTS(xsPrev.ts) {
|
||||
xssNew = append(xssNew, x{
|
||||
endStr: "+Inf",
|
||||
end: math.Inf(1),
|
||||
|
@ -87,6 +87,27 @@ foo{le="8.799e+05"} 5 123
|
||||
foo{le="+Inf"} 5 123`,
|
||||
)
|
||||
|
||||
// Multiple adjacent empty vmrange bucket
|
||||
f(
|
||||
`foo{vmrange="7.743e+05...8.799e+05"} 5 123
|
||||
foo{vmrange="6.813e+05...7.743e+05"} 0 123
|
||||
foo{vmrange="5.813e+05...6.813e+05"} 0 123
|
||||
`,
|
||||
`foo{le="7.743e+05"} 0 123
|
||||
foo{le="8.799e+05"} 5 123
|
||||
foo{le="+Inf"} 5 123`,
|
||||
)
|
||||
f(
|
||||
`foo{vmrange="8.799e+05...9.813e+05"} 0 123
|
||||
foo{vmrange="7.743e+05...8.799e+05"} 5 123
|
||||
foo{vmrange="6.813e+05...7.743e+05"} 0 123
|
||||
foo{vmrange="5.813e+05...6.813e+05"} 0 123
|
||||
`,
|
||||
`foo{le="7.743e+05"} 0 123
|
||||
foo{le="8.799e+05"} 5 123
|
||||
foo{le="+Inf"} 5 123`,
|
||||
)
|
||||
|
||||
// Multiple non-empty vmrange buckets
|
||||
f(
|
||||
`foo{vmrange="4.084e+02...4.642e+02"} 2 123
|
||||
|
@ -39,6 +39,7 @@ created by v1.90.0 or newer versions. The solution is to upgrade to v1.90.0 or n
|
||||
* BUGFIX: [vmbackup](https://docs.victoriametrics.com/vmbackup.html): fix snapshot not being deleted in case of error during backup. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/2055).
|
||||
* BUGFIX: allow using dashes and dots in environment variables names referred in config files via `%{ENV-VAR.SYNTAX}`. See [these docs](https://docs.victoriametrics.com/#environment-variables) and [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3999).
|
||||
* BUGFIX: return back query performance scalability on hosts with big number of CPU cores. The scalability has been reduced in [v1.86.0](https://docs.victoriametrics.com/CHANGELOG.html#v1860). See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3966).
|
||||
* BUGFIX: [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html): properly convert [VictoriaMetrics historgram buckets](https://valyala.medium.com/improving-histogram-usability-for-prometheus-and-grafana-bc7e5df0e350) to Prometheus histogram buckets when VictoriaMetrics histogram contain zero buckets. Previously these buckets were ignored, and this could lead to missing Prometheus histogram buckets after the conversion. Thanks to @zklapow for [the fix](https://github.com/VictoriaMetrics/VictoriaMetrics/pull/4021).
|
||||
|
||||
|
||||
## [v1.89.1](https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.89.1)
|
||||
|
Loading…
Reference in New Issue
Block a user