diff --git a/app/vmselect/promql/transform.go b/app/vmselect/promql/transform.go index 02257cc5c..c3a06735e 100644 --- a/app/vmselect/promql/transform.go +++ b/app/vmselect/promql/transform.go @@ -572,22 +572,23 @@ func vmrangeBucketsToLE(tss []*timeseries) []*timeseries { }) } xss = xssNew - if len(xss) > 0 { - for i := range xss[0].ts.Values { - count := float64(0) - for _, xs := range xss { - ts := xs.ts - v := ts.Values[i] - if !math.IsNaN(v) && v > 0 { - count += v - } - ts.Values[i] = count - } - } + if len(xss) == 0 { + continue + } + for i := range xss[0].ts.Values { + count := float64(0) for _, xs := range xss { - rvs = append(rvs, xs.ts) + ts := xs.ts + v := ts.Values[i] + if !math.IsNaN(v) && v > 0 { + count += v + } + ts.Values[i] = count } } + for _, xs := range xss { + rvs = append(rvs, xs.ts) + } } return rvs }