How to Compare Today vs Yesterday Metrics in Grafana Across Datasources
When building Grafana dashboards, one common question comes up again and again:
How does this metric compare with yesterday, last week, or before the last release?
I built CompareQueries, a Grafana datasource plugin for comparing time-shifted queries across datasources in one panel.
It is useful for workflows like:
- today vs yesterday/last week/custom dates dashboard comparison metrics
- time-shifted time-series dashboards before vs after
- day-over-day or week-over-week business metrics
- shifted comparison queries in Grafana Alerting
What It Does
CompareQueries lets you run the same query with different time shifts and display the results together in one Grafana panel.
It works with Prometheus, Loki, Elasticsearch, SQL, and other Grafana datasources through their native query editors.
For new dashboards, the recommended flow is:
- Create a panel with
-- Mixed --as the panel datasource. - Add a query row with
CompareQueries. - Pick the target datasource inside CompareQueries.
- Build the query with the datasource’s native query editor.
- Add time shifts such as
1d,1w, or30m.
Grafana 13+ and Alerting Support
CompareQueries supports Grafana 11, 12, and 13+.
For Grafana 13+ and new dashboards, it uses the Target Datasource flow because legacy RefId-style query references are no longer supported in Grafana 13+.
It also supports Grafana Alerting through backend query execution, so shifted comparison queries can be used in alert rules as well as dashboards.
Links
GitHub: https://github.com/leoswing/comparequeries-datasource-rc
Feedback, dashboard examples, feature requests, and bug reports are welcome.
If CompareQueries helps with your Grafana dashboards or alerting workflows, please consider giving the GitHub repo a star so more users can discover it.

Top comments (0)