grafana / loki

Like Prometheus, but for logs.
https://grafana.com/loki
GNU Affero General Public License v3.0
22.75k stars 3.31k forks source link

chore: [k209] fix(sharding): use without() grouping when merging `avg_over_time` shard results #13359

Closed grafanabot closed 5 days ago

grafanabot commented 5 days ago

Backport eb8a36306674c497d8b0150b482f275e2c00f6c9 from #12176


What this PR does / why we need it: avg_over_time expression that uses either keep or label_format stage without any aggregation fails on main with the following error: aggregation operator '"sum"' without grouping

Given these expressions contain stages that could reduce the labelset, sharding converts it to the following form sum (sum_over_time()) / sum(count_over_time()), but vector aggregation expr evaluator always expects a grouping. This pr updates the avg_over_time shard mapper to use without() grouping for generating vector agg expr when it is not explicitly set.

example query to reproduce this error:

avg_over_time({container="query-frontend"} |= `metrics.go` | logfmt | keep splits | unwrap split [$__auto])

Which issue(s) this PR fixes: Fixes #

Special notes for your reviewer:

Checklist