Parent/Child template variables using Interval type (with auto)

Hi,
I’m using Grafana 4.2 with InfluxDB 1.2 as data source.
I’ve created 2 template variables in a parent/child relation to dynamically select the InfluxDB retention policy based on the binning size:

  • $bin 10m,1h,1d,7d (type Interval, with auto enabled)
  • $retention SHOW TAG VALUES WITH KEY=“retention_policy” WHERE “bin” =~ /$bin/ (type Query, hidden)

The resulting query looks like:

  • select sum(value) from $retention.mymeasurement … group by time($bin)

Everything works as expected when explicitly choosing the bin size (10m, 1d, etc. ) but when ‘auto’ is selected I have the impression the $retention variable is computed using the previous $bin as value, as if somehow the auto evaluation happens after the parent/child evaluation. A simple reload of the dashboard (top right click) choose the expected retention policy.

A concrete example,

  • I’m on a plot showing last 2 hour of data with a ‘10m’ bin. On Influx, the ‘10m’ is mapped to a ‘fresh_data’ retention policy. So far so good, data is retrieved using the correct retention.
  • changing the $bin to ‘auto’, all good
  • then, time range is changed to ‘last 6 month’, that computes a bin of ‘6h’, which is mapped to the ‘old_data’ retention policy. What happen in reality is that the first time the plot is loaded, the ‘fresh_data’ is still used. Subsequent reload of the plot will correctly be populated querying the ‘old_data’ retention.

Any idea on what can be the issue and possibly how to cure it?

Thanks in advance,
Luca

A time range change updates the hidden auto variable state, but that will not trigger an update in your $retention variable as the state of the $bin variable as not changed (still auto). So time range change will not trigger an update in $retention variable.

Maybe you can get it to work if you set $retention variable to refresh on every time range change.

Hi Torkel,
thanks a lot for the answer (and for all the work on Grafana :wink: ). I’ve tried changing the refresh of $retention on time changes but it did not help, unfortunately. Also that would not explain why, even before, for further selections of longer time range, for example, the retention got chosen appropriately.
Cheers,
Luca