mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-11 15:34:56 +00:00
app/vmselect/promql: remove zero timeseries from prometheus_buckets
output
This commit is contained in:
parent
3f99f39e9b
commit
205233d9a7
1 changed files with 12 additions and 0 deletions
|
@ -343,12 +343,24 @@ func vmrangeBucketsToLE(tss []*timeseries) []*timeseries {
|
||||||
ts.MetricName.AddTag("le", leStr)
|
ts.MetricName.AddTag("le", leStr)
|
||||||
return &ts
|
return &ts
|
||||||
}
|
}
|
||||||
|
isZeroTS := func(ts *timeseries) bool {
|
||||||
|
for _, v := range ts.Values {
|
||||||
|
if v > 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
for _, xss := range m {
|
for _, xss := range m {
|
||||||
sort.Slice(xss, func(i, j int) bool { return xss[i].end < xss[j].end })
|
sort.Slice(xss, func(i, j int) bool { return xss[i].end < xss[j].end })
|
||||||
xssNew := make([]x, 0, len(xss)+2)
|
xssNew := make([]x, 0, len(xss)+2)
|
||||||
var xsPrev x
|
var xsPrev x
|
||||||
for _, xs := range xss {
|
for _, xs := range xss {
|
||||||
ts := xs.ts
|
ts := xs.ts
|
||||||
|
if isZeroTS(ts) {
|
||||||
|
// Skip time series with zeros. They are substituted by xssNew below.
|
||||||
|
continue
|
||||||
|
}
|
||||||
if xs.start != xsPrev.end {
|
if xs.start != xsPrev.end {
|
||||||
xssNew = append(xssNew, x{
|
xssNew = append(xssNew, x{
|
||||||
endStr: xs.startStr,
|
endStr: xs.startStr,
|
||||||
|
|
Loading…
Reference in a new issue