Interval variable does not correctly follow Date picker

On Grafana 5.4.3 with a Prometheus data source, I have a table of query data. This works fine when I explicitly enter the date range e.g. metric[2d].

But I would like the table data to change with the range selected in the date picker. I’ve used an interval variable, and this works up to a point, but I have two issues:

  1. When I change the date range, the table does not pick up the correct date range for some date range selections. The error consistently gives the same wrong values.

  2. How can I enter an offset in the query? So I can select e.g. ‘Last week’, which in Prometheus would be metric [7d] offset 7d.

More detail…
A selection of date ranges - as you can see, some are correct, some not:

date picker - interval

last 15 min - 15m
last hour - 1h
last 4 hours - 3h
last 23 hours - 12h
last 24 hours - 24h
last 2 days - 1d
last 6 days - 1d
last 7 days - 7d
last 30 days - 30d
last 31 days - 30d
last 90 days - 1y
today (and today so far) - 12h (regardless of time of day)

I want to see how many requests in the selected time range, as a list, per ‘method’.
My metric is
increase(iom_requests_per_method_counter [$TimeRange])

Where TimeRange is an interval variable. I originally tried __interval but this was not translated in the panel - why is that?

My time range config is shown below, and I have selected ‘auto’ in the variable drop-down.
image

I also created a text panel showing only the value of $TimeRange in order to verify the issue.
Shown here the date picker is set to ‘last 4 hours’ and the interval variable is ‘3h’.

Many thanks for any help on this.

1 Like