-
Notifications
You must be signed in to change notification settings - Fork 205
Open
Description
Problem
When executing Loki metric queries with aggregate functions like sum by() using the query_loki_logs tool, the results include metric values but all label groupings return as null.
Expected Behavior
Metric queries with grouping should return the labels that were grouped by. For example:
sum by(app, namespace) (count_over_time({namespace="dev2"} | json | Level="Error" [3h])) > 0
Should return results with app and namespace labels populated.
Actual Behavior
The query executes successfully but all results have "labels": null:
[
{"timestamp":"1761755580","line":"5","labels":null},
{"timestamp":"1761755623","line":"5","labels":null},
...
]Steps to Reproduce
- Configure Grafana MCP with a Loki datasource
- Execute a metric query with grouping:
query_loki_logs(
datasourceUid="<loki-uid>",
logql='sum by(app, namespace) (count_over_time({namespace="dev2"} [3h])) > 0',
...
)
- Observe that
labelsfield isnullin all results
Workaround
Instead of using metric queries, fetch raw log samples and extract labels from individual log entries.
Environment
- Grafana MCP version: latest (Docker image
mcp/grafana) - Transport: stdio via Docker
Metadata
Metadata
Assignees
Labels
No labels