Hi, I am on version 8.1.1
I created a dashboard variable as described here TimeFilter in panel name, values on graphs
I am using the following variable: $__interval
But it does not brings the right values(not always)
For instance when the interval 2days it returns 2
But when the interval is 45days (now-45d) the variable $__interval returns 30
Have you read our documentation about the
$__interval global variable? Here is a snippet about how it works and some other notes about using it with influx:
$__interval is calculated using the time range and the width of the graph (the number of pixels).
(to - from) / resolution
For example, when the time range is 1 hour and the graph is full screen, then the interval might be calculated to
2m - points are grouped in 2 minute intervals. If the time range is 6 months and the graph is full screen, then the interval might be
1d (1 day) - points are grouped by day.
In the InfluxDB data source, the legacy variable
$interval is the same variable.
$__interval should be used instead.
The InfluxDB and Elasticsearch data sources have
Group by time interval fields that are used to hard code the interval or to set the minimum limit for the
$__interval variable (by using the
> syntax →
Excellent. I found what I looked for.
Actually it should be something like Round((($__to) - ($__from) ) / (1000 * 60 * 60 * 24), 1) to get the dashboard selected time range in days.