Using Grafana version 10.1.2 with JSON API and Infinity datasources
Is there a way to set a variable based on the time span chosen in the dashboard?
I need to define the data resolution in my URL
http://myhost.org/api/measurement/param={hourly,daily,monthly,yearly}
I’ve looked at the $__range and $__interval variables, but they don’t work in any of the JSON datasource plugins. Is there another option?
I’d like to do something like:
if $__range < 7d:
${param} = ‘hourly’
elif $__range >= 7d and $__range < 30d:
${param} = ‘daily’
I’m currently letting the user select Hourly/Daily/Monthly/Yearly from a variable dropdown. But if the user selects Monthly and then chooses a one week timespan, they get no data. Likewise, if they choose Hourly and then define a 3 year timespan, the API will reject the request. I would to adjust this automatically.
Thanks