Search code examples
prometheusgrafanapromql

How to get query step OR count returned data points


My goal is to show the currently used step in a panel or in the panel title. The only way to know the step right now (at least from my knowledge) is to hover over a panel and look at the x-axis.

How can I get the step value?

I don't think that Grafana has a global variable that contains the step. There are only vars like $__range_s.

So now I am left with Prometheus. I'm trying to achieve it with something like this:

vector($__range_s) / count_datapoints(sum(counter_total[$__range_s]))

count_datapoints does not exist. I have tried count, but it counts the number of time series returned, not the number of points along the time axis. So, do you know da wae?


Edit: Please see my answer below, the question does not make sense for my use case.


Solution

  • Okay, flawed thought by me. The used step is not the same over a whole dashboard. So there is no way I could have a single panel that displays the current step.

    At best I could calculate it panel by panel and even this makes no sense even though this is possible with the alternative version of PromQL https://github.com/VictoriaMetrics/VictoriaMetrics/wiki/MetricsQL