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 <noreply@anthropic.com>
This commit is contained in:
@@ -51,8 +51,12 @@ pid = 0
|
|||||||
def panel(kind, title, w, h, x, targets, **extra):
|
def panel(kind, title, w, h, x, targets, **extra):
|
||||||
global pid
|
global pid
|
||||||
pid += 1
|
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},
|
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)
|
p.update(extra)
|
||||||
panels.append(p)
|
panels.append(p)
|
||||||
return p
|
return p
|
||||||
|
|||||||
Reference in New Issue
Block a user