Webhook icon
Schedule icon
Script icon
Process icon
Get icon
If icon
SlackIncomingWebhook icon
Set icon
Pause icon

Find Blind Spots in Grafana Alerting

Audit Grafana alert health, receiver routing and long-lived silences with Kestra; alert on changes and approve guarded silence expiry.

Categories
CoreInfrastructure

An alert rule can exist yet never reach on-call: its evaluation is in Error or No Data, its route references a missing receiver, or a long-lived silence hides it. This blueprint reads Grafana's live evaluation and Alertmanager configuration APIs together. It reports only changes in the issue set and can expire one reviewed silence after approval and a fresh read.

How it works

  1. validate_inputs checks the Grafana origin, horizon and requested silence ID before any API call.
  2. scan_grafana reads configured rules, live rule health, Alertmanager receivers and routes, and active silences. It emits a JSON report and stable issue fingerprint.
  3. read_previous and report_change compare the fingerprint with Kestra KV; a changed issue set produces one Slack message, then remember_digest updates KV. A first healthy audit is quiet.
  4. If allow_expiry names a flagged silence, wait_for_approval asks a human to keep or expire it. expire_if_unchanged checks the exact silence fields again, sends one DELETE, and confirms the expired state. Timeout cancels the run without a write.

Error handling

API reads retry transient HTTP 429/5xx and network failures. HTTP 200 bodies with status: error fail loudly. A missing receiver, unhealthy evaluation and excessive silence remain separate issues. A changed or no-longer-long-lived silence is never expired. DELETE is not blindly retried because its response may be uncertain; the error alert tells an operator to inspect Grafana first.

What this blueprint teaches about Kestra

A Webhook and disabled Schedule share one audit, KV suppresses repeat notifications, If isolates a human-approved branch, and Pause makes the destructive step visible. The final output is machine-readable for downstream flows.

Prerequisites

Grafana 12 with Grafana-managed alerts; Python 3 on the Kestra worker; a Grafana service account allowed to read alert rules, receivers, routes and silences (and expire silences only when that option is used); a Slack incoming webhook. The default URL targets a Grafana container named grafana-audit on the same Docker network.

Secrets

  • GRAFANA_API_TOKEN: service account bearer token; never embed it in the flow.
  • SLACK_WEBHOOK_URL: incoming webhook for changed issue sets and failures.

Inputs

  • grafana_url (STRING, default http://grafana-audit:3000): Grafana origin reachable by Kestra.
  • max_silence_hours (INT, default 168): active silences past this future horizon need review.
  • silence_id_to_expire (STRING, default empty): one exact silence to propose for expiry.
  • allow_expiry (BOOL, default false): enable the approval step for that candidate.

Outputs

  • audit_report (STRING containing JSON): configured/live rule counts and detailed issues on successful runs.
  • expired_silence_id (STRING): ID only after Grafana confirms expiry; otherwise empty. Failed runs do not emit flow outputs.

Quick start

  1. Add the two secrets and set grafana_url to your Grafana origin.
  2. Run manually. Fix the reported receiver or evaluation gaps; activate the disabled schedule or POST to the webhook after configuration changes.
  3. To expire a long-lived silence, copy its ID from audit_report, set allow_expiry=true and silence_id_to_expire, then review the Pause dialog. Re-running an unchanged audit does not repeat Slack.

Plugins used

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.