Hi!
I’m working with a Grafana datasource plugin that queries data from an external API, and I’m facing an issue for Grafana versions >= 11.3.0
Following scenario:
To optimise the cache hit rate of the queries the from
date of the query is rounded down in the query() method before sending the query, depending on a selected interval. To then also display the first returned data point in the timeseries graph, which would fall outside the time interval specified in the options.range
, I also round down options.range.from
using options.range.from.startOf(momentTimeUnit)
. This adjustment modifies the graph’s start date accordingly, aligning it with the rounded-down from
value making the first data point visible in the graph.
With version < 11.3.0 the options.range.from.startOf(momentTimeUnit)
adjustment didn’t persist between query()
calls. So the next query(options)
invocation would again contain the option.range values corresponding to the date selected in the Grafana date picker.
However and that’s the issue, with Grafana versions >= 11.3.0 the options.range.from.startOf(momentTimeUnit)
adjustment now persists between different query()
invocations. Values get only reset to the values selected in the Grafana date picker when the datepicker is changed or the refresh button clicked.
Two questions here:
-
I didn’t find any documentation on this change so I am not sure if this was an intentional behaviour change or would classify as a bug - does anybody have any insights there? The only maybe related bug report I found was this Issue: Dashboard variable, timepicker, and refresh settings not preserved correctly after navigating away and back in versions 11.3.x and 11.4.0 · Issue #97699 · grafana/grafana · GitHub
-
The method I’m using—
options.range.from.startOf(momentTimeUnit)
—feels a bit like a hack. Is there a more official or recommended way to adapt the start and end points of a timeseries graph in Grafana?
Thanks!