Global variable `$__rate_interval` does not work in variable template for Prometheus DS

Hello,

It seems the global variable $__rate_interval is not being expanded when we use it in Variables. If I have a query like rate(some_metric{instance="${host}"}[$__rate_interval]) in Query text box of Prometheus Data Source, it is being literally rendered in the HTTP request as

rate(some_metric{instance="somehost.example.org"}[$__rate_interval])

If I use $__interval or $__interval_ms, there are substituted by correct values. I noticed that $__rate_interval_ms does not work either. I am using Grafana 10.0.1.

Here is a screenshot on playground:

Is it a bug? I dont see any limitation on using $__rate_interval in variables in docs.

Cheers!!

Did you try $__rate_interval (not ${__rate_interval})?

Yes, I tried all the variations: $__rate_interval, ${__rate_interval}, "${__rate_interval}", "$__rate_interval".

What is your goal with that dashboard variable? I’m scratching a head but I don’t see a usage for rate values in dashboard variable.

Cheers for your responses @jangaraj !! Well, I am using same time series in multiple panels to show different types of metrics. So, I wanted to “cache” this time series and use it as template variable in different panels. But yeah, I figured out this hack would not work and maybe using “grafana” data source and directly using other panels as data source is a better solution.

Although my original use case does not make a lot of sense, a valid use case of using $__rate_interval in variables can be to get the maximum/minimum rate of a metric within a range?

yes, use:

That’s not a case for range query, but for instant query (so you don’t need $__rate_interval in this case)

1 Like