Skip to content

CICD-354 · Grafana dashboard validation ​

Encyclopedia · Observability and SRE pipelines · All snippets

Previous · CICD-353 · Next · CICD-355

1. Where it fits ​

  • Placement CI run step.
  • Prerequisites staging metrics stack, provisioned endpoints and read-only CI identity except explicitly approved writes.
  • Platforms local-linux, github-actions, gitea-actions.

2. Copy the snippet ​

bash
for file in monitoring/dashboards/*.json; do jq -e '.uid and (.panels | type == "array")' "$file" || exit 1; done
jq -r '.uid' monitoring/dashboards/*.json | sort | uniq -d | grep . && exit 1 || test "${PIPESTATUS[0]}" -eq 0

3. How it works ​

The expression filters or transforms the input JSON. Where jq -e is used, a false or empty result can fail the gate. The shell predicate makes the expected state explicit and returns a nonzero status when it is not satisfied.

4. Verify the result ​

Check shape and detect duplicate dashboard UIDs before provisioning. Test imports against the Grafana version you deploy.

Validation syntax-validated (Bash parse). Status definitions.