TimeFilter in panel name, values on graphs

Hello,
I`ve got 2 questions.
First, how i can put ‘timefilter’ variable in panel/dashboard title. I want to do something like "Data in last $__timeFilter days. "
Second, i want to present one graph with one line in percentage, but if i hover on data point i want to see this value (%) and second non-relative value.

Thanks

I am also trying to get the selected time range displayed in a panel title.

I’ve read https://grafana.com/docs/grafana/latest/reference/templating/ which
says near the top “You can use variables in metric queries and in panel
titles.” and then at the bottom lists built-in variables:

$__interval
$__timeFilter

So, I’ve tried using __interval and [[__interval]] in my panel titles, and I get literally that text: "__interval" or “[[__interval]]” - the variable name
doesn’t get de-referenced to its value.

What am I doing wrong? I want to get the text of the time range selected
using the standard dashboard drop-down list (top right) to be displayed as
part of the panel title.

If I create my own variable and have a drop-down selector for it at the top
left of the dashboard, then I can get exactly what I want - something such as
[[Timescale]] gets de-referenced to “7 days” in the panel title.

But defining my own time range variable when there’s already a standard built-
in system facility for this seems somewhat unnecessary.

Thanks in advance,

Antony.

Here are my workaround for this topic.

I think you can’t use al kind of variables on a dashboard surface.
My solution is to define a new dashboard variable.
Here is an example how to display the “$__interval” in the panel header.

Now you can use the new variable in the panel.
2019-12-17_13h01_08

Jo

Hi.

Thanks for the suggestions (it’s an interesting workaround), but it doesn’t
work for me.

As soon as I enter “select __interval" or "select __interval_ms/1000” into
the Query box, I get the error message:

Template variables could not be initialized: error parsing query: missing
parameter: __interval

Then, where I use my variable name in the panel title I get “undefined”.

Any ideas?

Antony.

Hi Antony,
I think it depents on the selected Data source. In my case with MySQL and MS SQL it works flowless.
“select $__interval/1000”

Hi Jo

Its an old post, I am trying to do exactly your solution here only with $__timeFilter, interval works perfectly like you show but I cannot get time filter to work, do you have any suggestions for this?

Hi, in Grafana 8 I did the same ì. I create a variable as query: INSERT ‘$__interval’ but it always show me 1s

hi @donatod
$__interval is different from $__timeFilter (timefilter being the variable that this post is looking to show in the title, and i assume you too are looking to show, ie if you graph is the past 7d , via the time picker, i assume you want “7d” to show in your panels title

so when you see 1s for $__interval , that is correct (as the interval in your graph/panel is 1sec, look under “Query Options” drop down, when in the edit panel page.

that said, i dont know the answer to: what is the variable to use in Panel Title so that it shows the current, live updated, time-picker’s “TimeFrame” (ie the 7d or 7day in my example above).

I know i have had this working in my some of my prior panel’s titles, but i cant seem to get it working again (or im using the wrong variable , also). according to the docs, it should be variable:
$__timeFilter
but that does not resolve to anythnig for me on grafana v9.02 (with a graphite DS and using the Time-series panel type).

sorry i have no answer for you (hopefully someone else does)
(LOVE GRAFANA)

Hi,
I would like to open this issue again, as in Grafana 9.3.6 it is still not working.
According documentation, there is written you can use it in queries, which is great, but… why is it such a problem, to implement it to show also in panel titles?

Has anyone a sollution to this since last year?

PS: I’ve opened also a feature request on github: $__timeFilter in panel Title · Discussion #63238 · grafana/grafana · GitHub

Thanks
Gustonator