Labels icon
Get icon
OutputValues icon
Fail icon
If icon
Commands icon
Docker icon
Log icon
Exit icon
Pause icon
Set icon
Assert icon
SlackIncomingWebhook icon
Schedule icon

Switch Grafana to a new Prometheus backend with query parity proof

Compare every Grafana PromQL query on two backends before moving to Prometheus 3, VictoriaMetrics or Mimir. Repoint dashboards after approval and roll back.

Categories
Infrastructure

Moving dashboards to Prometheus 3, VictoriaMetrics, Mimir or Thanos usually means changing a datasource and looking at the panels. A panel that fails or shows different numbers is found by whoever opens it. This flow collects every PromQL query of your dashboards and of the old backend's rules, runs each one on both backends over the same window. It shows which panels would answer differently before any dashboard is changed.

How it works

  1. collect reads the dashboards that use the source datasource, fills in the template variables and $__rate_interval. It lists every expression and the rules of the old backend.
  2. parity runs each query with query_range on both backends and compares the series and the values. Each query ends as MATCH, DIFF, ERROR (the new backend rejects it), EMPTY_TARGET (no data there) or EMPTY_BOTH.
  3. approve_switch (Pause) offers SWITCH_CLEAN for the dashboards whose panels all match. SWITCH_ALL needs a note.
  4. switching creates a datasource for the new backend, checks its health and repoints the dashboards. A dashboard that was saved after the analysis is left alone.
  5. verify_switch asks Grafana the same queries through the old and the new datasource, so the proxy and the credentials are part of the proof.
  6. ROLLBACK restores the previous dashboard versions unless someone saved a dashboard since.

What you get

A list of panels that break, with the reason. On the test cluster Prometheus 3.5 rejected holt_winters. VictoriaMetrics returned rate() values up to 21% apart and kept metric names that Prometheus drops.

Who it's for

Platform teams that upgrade Prometheus or move to VictoriaMetrics, Mimir, Thanos or a managed service.

Why orchestrate this with Kestra

The queries come from Grafana itself, so nothing is listed by hand. Pause shows the counts. KV keeps what was changed. Assert fails the run when a dashboard that matched answers differently through Grafana.

Tested end to end

18 runs on Kestra 2.0.6 with Prometheus 2.55.1 as the source, Prometheus 3.5.0 and VictoriaMetrics 1.122.0 as targets and Grafana 11.6.0. Covered: identical backends, a rejected function, rate differences, a target without data, an unhealthy datasource, a dashboard saved during the approval, a rerun, rollback and a dashboard saved after the switch. Mimir, Thanos and managed services were not run.

Prerequisites

Grafana with a service account token (Editor role) and an old Prometheus-compatible backend that both Kestra and Grafana can reach. Docker workers must reach Grafana and both backends.

Secrets

GRAFANA_TOKEN and SLACK_WEBHOOK_URL. Tenant headers go into the two header inputs.

Inputs

source_datasource_uid, source_url and target_url are required. window and step set the comparison. ignore_labels leaves labels out. dry_run defaults to true and auto_remediate to false.

Quick start

  1. Run ANALYZE and read the report in the show_report log.
  2. Run SWITCH with the defaults to see the plan.
  3. Set dry_run false and auto_remediate true, run SWITCH and approve.

How to extend

Grafana alert rules and rule files are listed but not moved. Add a task that copies them after the switch. Raise rel_tol where a small gap is acceptable.

Links

This blueprint was created by zkasuran.

See How

New to Kestra?

Use blueprints to kickstart your first workflows.