How to get the time range selected on the dashboard into a variable

Hello,

Is there any way i can get the time range we selected on the dashboard into a variable, so that i can use the same in my query.

I wanted to have a single stat for TPS for the time i selected on the dashboard . I have the total number of requests from influx db. How can i get the time selected on the dashboard into a template variable so that i can use. Please help.

Please help

This is currently not possible

Thanks for the update.

Anyone know if it’s possible now?

Would built in variable $__range do the trick for you?

It’s my understanding that $__range is only supported for a Prometheus data source, and mine is MySQL, so I think not, but if you know a way to use it with MySQL that would be awesome

Grafana Docs suggest to use $__timeFilter for MySQL: https://grafana.com/docs/grafana/latest/variables/variable-types/global-variables/#timefilter-or-__timefilter

What I’m looking to do is a simple SELECT to just display the amount of time in the select time range. For some reason when I use $__timeFilter I get the ERROR :Unknown column '$__timeFilter' in ‘field list’.