-
Notifications
You must be signed in to change notification settings - Fork 1
Home
leoswing edited this page May 25, 2026
·
4 revisions
CompareQueries is a Grafana datasource plugin that lets you compare the same query across multiple time shifts (for example: current vs yesterday, last week, or custom offsets) in a single panel.
- Plugin ID:
leoswing-comparequeries-datasource - Marketplace: https://grafana.com/grafana/plugins/leoswing-comparequeries-datasource/
- Repository: https://github.com/leoswing/comparequeries-datasource-rc
- License: Apache-2.0
Grafana’s native time-shift is often panel-wide. CompareQueries enables query-level comparison workflows so you can:
- Compare baseline and shifted series in one view
- Keep native query editing for the target datasource
- Reuse the same logic in dashboards and Grafana Alerting
Typical use cases:
- Day-over-day and week-over-week analysis
- Release before/after verification
- Capacity and anomaly comparison
- Cross-datasource observation with
-- Mixed --panels
- Grafana 10 / 11 / 12 / 13+
- Works with Prometheus, Loki, Elasticsearch, SQL, and other datasources via target datasource query editor
- Backend execution for Grafana Alerting is supported
Important:
- For new dashboards (especially Grafana 13+), use Target Datasource flow.
- Legacy RefId flow is for existing Grafana 11/12 dashboards only.
- Install plugin from Marketplace or Grafana CLI:
grafana-cli plugins install leoswing-comparequeries-datasource
- Add a CompareQueries datasource in Connections -> Data sources.
- Create a panel and set panel datasource to -- Mixed --.
- Add a query row and choose CompareQueries.
- In CompareQueries editor:
- Select Target Datasource
- Build the target query inline
- Add one or more Time shift rows (1d, 1w, 30m, etc.)
- Optional: enable Process TimeShift to align shifted timestamps with current time window.
Default mode:
- Authentication (Optional): No Authentication
Only if backend/alerting requests fail authentication:
- Switch to Basic authentication
- Configure:
- Service Account Token
- optional Grafana URL (only if auto-detection is incorrect)
CompareQueries supports alerting through backend query execution.
Minimal alerting setup:
- Use CompareQueries datasource directly in alert rule query.
- Configure target datasource + query + time shifts.
- Add alert expressions (for example Reduce + Threshold).
- If auth errors happen, configure Basic authentication as described above.
For existing Grafana 11/12 dashboards:
- Open old CompareQueries row (Reference Query refId set).
- Click Migrate to Target Datasource.
- Select original datasource.
- Rebuild query in embedded editor.
- Save dashboard.
Migration preserves time-shift rows and related options.
- README: https://github.com/leoswing/comparequeries-datasource-rc/blob/main/README.md
- Developer guide: https://github.com/leoswing/comparequeries-datasource-rc/blob/main/developer-guide.md
- Releases: https://github.com/leoswing/comparequeries-datasource-rc/releases
- Issues: https://github.com/leoswing/comparequeries-datasource-rc/issues
- Installation
- Query Editor Guide
- Alerting Guide
- Migration Guide (RefId -> Target Datasource)
- Troubleshooting / FAQ
- Release Notes Highlights