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,