Why $_interval does not work and looks like a pixel in Grafana?

Vastly
2 min readApr 25, 2020

--

As per Grafana documentation:

Grafana automatically calculates an interval that can be used to group by time in queries. When there are more data points than can be shown on a graph then queries can be made more efficient by grouping by a larger interval. It is more efficient to group by 1 day than by 10s when looking at 3 months of data and the graph will look the same and the query will be faster. The $__interval is calculated using the time range and the width of the graph (the number of pixels).

Well, $_interval is indeed calculated automatically, right? Not exactly. You have a chance to add some panels to your dashboard using grouping by automatic, self-adapting interval, like this:

Using $__interval in Grafana

and see the following picture:

Nulled $__interval in action

What 😲? It looks like Grafana’s interval is squashed into quantum particle, or a pixel, instead of something valuable. When you change the grouping in query to 1s or something else, everything looks normal.

In my case, solution is enabling Min time interval option in data source settings:

The inline documentation clearly states that it is just a “lower limit” for beforementioned interval, not the on/off switch. But without this setting enabled, whole funcitonality does not work at all ¯\_(ツ)_/¯. This is how it looks right after enabling the setting:

TLDR: If Grafana’s $__interval seems to be a pixel instead of meanful value, try to assign something to ‘Min time interval’ in the data source settings.

--

--