-
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 for comparing 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 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 11, 12, and 13+
- Works with Prometheus, Loki, Elasticsearch, SQL, and other datasources through target datasource query editor
- Backend execution for Grafana Alerting is supported
Important:
- For new dashboards (especially Grafana 13+), use the 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
2. Add a CompareQueries datasource in Connections -> Data sources.
3. Create a panel and set panel datasource to -- Mixed --.
4. Add a query row and choose CompareQueries.
5. In CompareQueries editor:
- Select Target Datasource
- Build the target query inline
- Add one or more Time shift rows (1d, 1w, 30m, etc.)
6. Optional: enable Process TimeShift to align shifted timestamps with current time window.
## Datasource settings and auth
Default mode:
- Authentication (Optional): No Authentication
Only if backend or alerting requests fail authentication:
- Switch to Basic authentication
- Configure Service Account Token
- Configure Grafana URL only if auto-detection is incorrect
## Grafana Alerting
CompareQueries supports alerting through backend query execution.
Minimal setup:
1. Use CompareQueries datasource directly in alert rule query.
2. Configure target datasource + query + time shifts.
3. Add alert expressions (for example Reduce + Threshold).
4. If auth errors happen, configure Basic authentication as described above.
## Migration from legacy RefId flow
For existing Grafana 11/12 dashboards:
1. Open old CompareQueries row (with Reference Query refId set).
2. Click Migrate to Target Datasource.
3. Select original datasource.
4. Rebuild query in embedded editor.
5. Save dashboard.
Migration preserves time-shift rows and related options.
## Wiki pages
- Quick Start (Quick-Start)
- Alerting (Alerting)
- Troubleshooting (Troubleshooting)
- FAQ (FAQ)
## Project links
- 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