Is it possible to define a custom variable which represents the built-in $__interval variable, but the value will not go below a certain threshold (e.g. 15s)?
Background / problem I want to solve (InfluxDB datasource):
Currently I’m using |> aggregateWindow(every: $__interval, fn: last)
which is needed to avoid the Error “A query returned too many datapoints and the results have been truncated…” when a large time range (e.g. 7 days which will set $__interval to 5m) is selected.
But on the other hand, when I zoom in to e.g. 3 hours (which will set $__interval to 10s), the time series visualization look chopped (unsure why). As long as I go not below 15s the visualization is fine.
Your solution introduces a dropdown where the user can choose between different intervals.
Sure, with this approach I can guarantee that the interval is never below a certain threshold.
But I lose the automatic adjustment of the interval for different time ranges, right?
I was thinking of an approach where I can “calculate” the value of a custom variable based on another variable, e.g. (pseudocode):
I use it often - it is visible variable for users. I use default auto value, but user can select own period and that will force aggregation based on current user needs.
Of course there is a risk that user will select options which may kill performance of used TSDB (e.g. 1min aggregation for last 2 days).
Thanks to both of you . Indeed, this is possible and makes sense.
But now I realized, that Grafana offers a super simple solution for that (no variable definition needed):
Just open the “Query options” section to the right of the InfluxDB datasource and set “Min interval” (for me it was set to 10s, probably I set that some time ago and forgot about it… )