diff --git a/app/vmselect/promql/transform.go b/app/vmselect/promql/transform.go index c83616dd1..02257cc5c 100644 --- a/app/vmselect/promql/transform.go +++ b/app/vmselect/promql/transform.go @@ -572,19 +572,21 @@ func vmrangeBucketsToLE(tss []*timeseries) []*timeseries { }) } xss = xssNew - 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 + 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 } - ts.Values[i] = count } - } - for _, xs := range xss { - rvs = append(rvs, xs.ts) + for _, xs := range xss { + rvs = append(rvs, xs.ts) + } } } return rvs