From cece114d98f43c4eea47a528f01a309962297363 Mon Sep 17 00:00:00 2001 From: rays Date: Wed, 14 Oct 2026 00:09:32 +0000 Subject: [PATCH] Grafana: a panel querying Loki and Prometheus both is Mixed, so Downloads works (#226) Each panel took its first query's data source, Loki for Downloads, whose at-once and torrent lines are Prometheus's; Grafana runs another data source's query only on a Mixed panel. Co-Authored-By: Claude Opus 5.5 --- grafana/dashboard.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/grafana/dashboard.py b/grafana/dashboard.py index ab50b74..c7bf19f 100644 --- a/grafana/dashboard.py +++ b/grafana/dashboard.py @@ -51,8 +51,12 @@ pid = 0 def panel(kind, title, w, h, x, targets, **extra): global pid pid += 1 + sources = {t.get("datasource", LOKI)["uid"] for t in targets} + # A panel with queries on more than one data source must be Mixed, or Grafana runs them all on + # the panel's and Downloads, Loki's and Prometheus's, failed (#226). + ds = {"type": "datasource", "uid": "-- Mixed --"} if len(sources) > 1 else targets[0].get("datasource", LOKI) p = {"id": pid, "type": kind, "title": title, "gridPos": {"x": x, "y": y, "w": w, "h": h}, - "datasource": targets[0].get("datasource", LOKI), "targets": targets} + "datasource": ds, "targets": targets} p.update(extra) panels.append(p) return p