robo
September 11, 2020, 7:48pm
1
I don’t want to manually select the best retention bucket for my query, and I certainly don’t want the users of my grafana ui to have to.
I want influx to automatically select the bucket with the best granularity of data, that contains data with the range I have specified.
talek’s excellent attempt to work around the issue is here:
opened 12:32PM - 05 Mar 16 UTC
closed 10:12AM - 30 Nov 21 UTC
type/feature-request
datasource/InfluxDB
prio/medium
area/datasource
Hi,
I'm currently looking at how to make Grafana use the aggregated retention po… licies in InfluxDB.
Issue #3943 apparently adds a way to set the retention policy statically for a query but this only works if you have a hand full of queries. The moment you have more dashboards this is not really a viable option.
What I'd rather like to propose is the ability to add a table in the settings that defines a retention policy based on time ranges. For example you would define the values like this:
1 month => retention_one_value_per_day
1 week => retention_one_value_per_hour
1 day => retention_one_value_per_10s
All queries in all dashboards would then use the retention policy closest to the selected time range as default (which could still be overridden on a per-query basis by explicitly selecting a retention policy there?). If the user doesn't define this table then the default retention policy would always be used.
With this approach most people would be able to set up this table once and then all dashboards would automatically always use the right retention policy for their data which is I think what 99% of the people out there expect. Also for anyone who doesn't specify this value Grafana will behave just as before.
However it only works if your end time $__to happens to be now.
taleks example can however be placed into mysql instead of influx in order to use it’s now() function to achieve the desired result from grafana (Since you can have a mix of datasources).
i.e.
so instead of having to hunt
from(bucket:"my_db/autogen")
|> range(start: a_long_time_ago, end: some_time_after_that)
NO DATA
from(bucket:"my_db/a_while_back")
|> range(start: a_long_time_ago, end: some_time_after_that)
THE TAIL END OF THE DATA!
from(bucket:"my_db/a_long_while_back")
|> range(start: a_long_time_ago, end: some_time_after_that)
DATA!
Instead
from(bucket:"my_db", range(start: a_long_time_ago, end: some_time_after_that))
should work out the the shortest retention policy that encompasses the range specified
i.e.
the a_long_while_back policy.