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