skip to content

Grafana dashboards offer a template variable of type 'Interval'. How do you configure its list of durations and its `auto` entry, how does the selected value reach a panel query, and when should the resolution be a user-visible choice rather than left to the duration Grafana computes for each panel?

level: middleimportance: should knowfreq 36%

answer

  1. Type Interval = literal `1m,5m,1h` list, no data source query
  2. auto entry = range ÷ step count, floored by minimum, rounded
  3. one value for the whole dashboard, not per-panel pixel width
  4. travels in the URL as `var-<name>=<value>`
  5. single-valued: cannot repeat panels

basics

~20 s

You give it a literal comma-separated list of durations, optionally plus an auto entry computed from the dashboard time range divided by a configured step count and floored by a minimum. It interpolates by name, appears in the URL, and is one value shared by all panels.

solid answer

~50 s

An **Interval** variable is a drop-down of durations the operator picks. You type the options literally (`1m,5m,10m,1h,6h,1d`) — nothing is queried from a data source. You can enable an **auto** entry with two settings: a **step count** (how many buckets the visible range is divided into) and a **minimum interval** (a floor, default `10s`); Grafana divides the dashboard time range by the step count, applies the floor, and rounds to a friendly duration. It interpolates by the name you chose — `$resolution` / `${resolution}` — into queries, panel titles and text panels, and the choice is written into the URL as `var-resolution=5m`, so links and snapshots reproduce it. It is single-valued, so it cannot repeat panels. Reach for it when the duration is semantic ("orders per hour"), when every panel must agree, or when an operator should trade resolution for cost. Leave pure downsampling to the panel's own computed interval macro.

code

text · 12 lines
text
name:        resolution
type:        Interval
values:      1m,5m,10m,30m,1h,6h,1d
auto option: on   step count = 30   minimum = 10s

dashboard range = 6h, user picks "auto"
  candidate = 6h / 30 = 12m  -> above the 10s floor -> rounded to a friendly duration
  every panel on the dashboard sees the SAME value

user picks "1h" instead
  $resolution -> 1h
  URL         -> ...?var-resolution=1h   (shareable, reproducible)

go deeper

for a junior

Know that it is a drop-down of durations you type in yourself, that it interpolates as $name in the query, and that picking a value changes every panel that uses it.

for a middle

Be able to configure it end to end: the literal option list, the auto entry with its step count and minimum, how the value appears in the URL, and that it is single-valued.

for a senior

Argue the choice — expose the variable when the window is semantic or must be identical across panels or reproducible in a link; leave pure downsampling to the panel's own computed interval, and never hardcode a duration where either belongs.

for a principal

Treat it as dashboard contract design: which durations the fleet is allowed to ask for given the collection interval and store cost, whether resolution is an operator lever during incidents, and how the same query text is expressed in alert rules where dashboard variables do not resolve.

## The problem the variable solves Almost every dashboard query contains a duration somewhere: the bucket a group-by rolls into, the window a range function looks back over, the granularity of a SQL time bucket. Grafana can compute a sensible duration *per panel* from that panel's own query options — that is the panel-query macro mechanism (`$__interval`, `$__rate_interval`), and its derivation belongs with panel time-range, max-data-points and min-interval settings. The **Interval template variable** is the other option: a duration a *person* chooses from a drop-down at the top of the dashboard. ## Configuring it Add a variable and set its type to **Interval**. Its "query" is a literal comma-separated list of durations — `1m,5m,10m,30m,1h,6h,1d`. Each entry becomes one option; the list is static, so unlike a Query variable nothing about the data influences what is offered. Optionally enable the **auto** option, which prepends an `auto` entry governed by two settings: - **Step count** — how many buckets the visible range should be divided into. Grafana offers a fixed set of counts (1–5, 10, 20, 30, 40, 50, …). With a 6-hour range and a step count of 30, the raw candidate is 12 minutes. - **Minimum interval** — a floor (default `10s`) the computed value may never fall below, so zooming into a one-minute window does not ask the store for buckets finer than the data exists at. Grafana then rounds the candidate to a friendly duration, and that is the variable's value. Two properties matter. First, the calculation uses only the dashboard time range and the variable's own two settings. Second, the result is **one value shared by every panel**. That is the substantive difference from the panel macro, which each panel derives from its own max data points (defaulting to its rendered pixel width) and can therefore resolve differently on a full-width panel than on a narrow one in the same row. ## How the value reaches a query It interpolates by the name you gave it: `$resolution`, `${resolution}` when it must abut other characters, `[[resolution]]` in the legacy syntax. Because it is a genuine variable rather than a query-time macro, the value also: - appears in the dashboard URL as `var-resolution=5m`, so a shared link, bookmark or snapshot reproduces exactly the resolution the author was looking at; - can be referenced in panel titles, descriptions, text panels and data links, letting a graph state the bucket it is drawing ("errors per $resolution"); - is single-valued — Interval variables are not multi-value, so they cannot drive panel or row repetition and the multi-value formatting options do not apply. ## When a human should own the number Use an Interval variable when the duration is **semantic** rather than cosmetic: - The bucket *is* the business question — "orders per hour", "daily active users". Fitting the bucket to the pixel width silently changes what the number on screen means. - Panels must agree with each other. Cross-panel comparison only holds if both aggregate over the same window; a per-panel computed step lets two panels disagree. - The operator is deliberately trading resolution against query cost. On a large store, letting someone drop from `1m` to `1h` during an incident is a cheap escape hatch. - The view must be reproducible from a link or a screenshot: the chosen value travels in the URL, a pixel-derived one does not. Leave the number to the panel's computed interval when it is pure downsampling — "draw about one point per pixel, don't fetch more than the screen can show". A drop-down there only gives users a control that can make the graph worse. The macro-side decision rule is unchanged and not this leaf's subject: `$__rate_interval` inside rate/increase-style windows, `$__interval` for step and group-by. If you expose an Interval variable, it *substitutes* for one of those in the query; it does not stack with them. ## Failure modes to name - **Hardcoding the duration.** A literal `[5m]` or `date_trunc('hour', …)` is right at one zoom level and misleading at every other — the panel stops responding to the time picker. Either a variable or a macro belongs in that slot. - **Offering options below the collection interval.** A `1s` entry against a source collected every 30s hands users a choice that produces empty buckets. - **Auto with no sensible minimum.** Zooming far in drives the computed value pathologically small: more work, no more information. - **Reusing the query in an alert rule.** Alert rules evaluate outside a dashboard and cannot resolve dashboard template variables, so the window must be written explicitly there. - **Expecting it to repeat panels.** Repetition needs a multi-value variable; an Interval variable is a single duration. ## Interview framing Say what it is (a literal duration list plus an optional auto entry with step count and minimum), how the value travels (interpolates by name, shows up in the URL, one value for the whole dashboard), and then land the judgment: expose it when the window is meaningful or must be identical across panels, and leave it to the panel's own computed interval when it is only about not fetching more points than can be drawn.

  • Two panels sit side by side on the same Grafana dashboard, one full width and one narrow. Why can the duration Grafana computes for each panel differ, while an Interval variable's auto value cannot?
    The panel-computed interval is derived per panel from that panel's max data points, which defaults to its rendered width in pixels, so a narrow panel gets a coarser step than a wide one. The Interval variable's auto value is computed once from the dashboard time range and the variable's own step count and minimum, with no reference to any panel, so all panels interpolate the identical string. That is exactly why you reach for the variable when panels must be comparable.
  • Can an Interval variable be used to repeat a row or panel across several bucket sizes?
    No. Repetition requires a multi-value variable, and Interval variables hold a single selected duration — there is no multi-value or 'Include All' mode for them. If you genuinely need one panel per bucket size, use a Custom variable listing the durations and mark it multi-value, accepting that you have given up the auto entry and its floor.
  • An operator opens a shared dashboard link and sees a different aggregation window than the author described. What do you check first?
    Whether the link carried the variable state. Template-variable selections travel as `var-<name>=<value>` query parameters; a link copied without them lands the viewer on the variable's saved current value or its default option instead. Check the URL, then check whether the dashboard was saved with a different current value than the author was using.

saying these in an interview costs you the question

  • Claiming the Interval variable's auto value is derived from the panel width or max data points — it is computed from the dashboard time range, the step count and the minimum only.
  • Saying the option list is fetched from the data source; it is a literal comma-separated list you type.
  • Treating it as interchangeable with the panel's computed interval macro even when panels must agree — the macro can resolve differently per panel.
  • Assuming it can be multi-value or drive panel/row repetition.
  • Hardcoding a window such as `[5m]` in the query and adding the variable anyway, so the drop-down changes nothing.
  • Copying a query containing `$resolution` into an alert rule and expecting the variable to resolve there.

context