Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions scripts/check_dashboards.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* every datasource UID resolves to one declared in provisioning;
* every dashboard UID is unique across the folder;
* panels fit the 24-column grid and do not overlap;
* every panel has at least one target.
* every panel that queries data has at least one target.

Additionally, every PromQL expression is emitted to stdout in Prometheus
recording-rule form when --emit-promql is passed, so promtool can parse them.
Expand All @@ -28,6 +28,16 @@
# UIDs Grafana provides itself.
BUILTIN_UIDS = {"-- Grafana --", "-- Mixed --", "-- Dashboard --", "grafana"}

# Panel types that legitimately carry no targets.
#
# row and text render no data at all. alertlist is different and worth naming:
# it does read from a datasource, but not through a query — it pulls alerts from
# the Alertmanager datasource named in its own options, so a targets array would
# be meaningless. Requiring one here would have forced a fake target onto every
# alert panel, which is exactly the kind of thing that teaches people to work
# around this script rather than trust it.
TARGETLESS_PANEL_TYPES = {"row", "text", "alertlist"}


def declared_datasource_uids() -> set[str]:
"""Read provisioned UIDs without requiring PyYAML."""
Expand Down Expand Up @@ -116,7 +126,7 @@ def main() -> int:
f"{name}: panel '{title}' overflows the 24-column grid "
f"(x={grid['x']} w={grid['w']})"
)
if panel.get("type") not in ("row", "text") and not panel.get("targets"):
if panel.get("type") not in TARGETLESS_PANEL_TYPES and not panel.get("targets"):
problems.append(f"{name}: panel '{title}' has no targets")

for other in panels[i + 1:]:
Expand Down
61 changes: 47 additions & 14 deletions stacks/observability/grafana/dashboards/docker-containers.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading