Skip to content
Tutorials Center
My learning

Topics

Lesson 26 of 37 ยท Dashboards and Variables

Repeating Panels and Rows in Grafana, and the 24-Column Grid

Build dashboards that grow with your data: repeat panels and rows by a multi-value variable, control direction and max per row, and understand Grafana's 24-column grid.

If you monitor five servers, you do not want to copy a CPU panel five times. You want one panel that repeats once per server, and grows to six panels when a sixth server joins. Grafana does this by repeating a panel or a whole row for every value selected in a multi-value variable. This lesson explains how repeats work, how the grid decides where panels go, and how to keep layouts tidy.

Grafana is not available here, so the steps describe the interface. The TryIt blocks are Python stand-ins that simulate the layout arithmetic and the repeat expansion.

The grid

Dashboards in Grafana use a grid that is 24 columns wide. Each panel has a position (x, y) and a size (w columns, h rows) stored in its gridPos. One grid row unit is a small fixed number of pixels, so a panel of h: 8 is a typical medium-height graph. A panel of w: 12 is half the width, w: 8 one third, w: 6 one quarter, w: 24 full width. Panels cannot overlap; if you drag one onto another, Grafana pushes the others down.

Good sizes: stat panels w: 4 to 6, h: 4; time series w: 12, h: 8; tables w: 24.

Repeating a panel

  1. Define a variable with Multi-value or Include All enabled (see dashboard variables), for example $host.
  2. Edit the panel, open Panel options > Repeat options.
  3. Choose Repeat by variable: host.
  4. Choose Repeat direction: Horizontal (panels laid out side by side and wrap) or Vertical (stacked in a column).
  5. For horizontal repeats set Max per row to limit how many sit on one line.

Now select three hosts: Grafana draws three panels. Inside each copy, $host holds a single value, so queries such as node_cpu_seconds_total{instance="$host"} work as written. Panel titles can use it too: CPU on $host. The original panel is the template; you edit only that one.

Notes:

  • The repeated panels are created when the dashboard loads, not saved in the JSON. Only the template with its repeat setting is stored.
  • With All selected and many values, you may get dozens of panels and as many queries. Limit the variable or use a regex to cap the list.
  • The first copy shows the first selected value; Grafana arranges the copies from the template's position, and panels below shift down.
  • In newer versions that use the Scenes framework, the repeat options are in the same place under the panel options, and the layout rules are the same.
Python Stand-in: expand a repeated panel

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The four copies wrap into two rows of two panels, 12 columns each. In Grafana the copy width comes from "Max per row" as well, so a smaller number makes the panels wider.

Repeating a row

A row is a collapsible header that groups panels. Rows repeat too, which is better when you want a whole section per item: for example, one row per service with request rate, error rate and latency panels inside.

  1. Add a row (Add > Row, or the Edit mode's add menu) and give it a title with the variable: Service $service.
  2. In the row's settings (the gear icon on the row title), choose Repeat for and pick the variable.
  3. Put the panels inside the row.

For each selected value you get a copy of the row with its panels, stacked vertically, each titled with the value. Panels inside a repeated row must not use their own panel-level repeat. Each row can be collapsed so viewers focus on one service, and collapsed rows skip their queries until opened, which speeds up large dashboards.

Layout and performance tips

  • Group by purpose: a "Overview" row with stat panels, then rows for details. Put the most important numbers at the top left.
  • Collapse detail rows by default so the dashboard loads fast; collapsed rows do not query until expanded.
  • Use the same height inside a row so the grid looks regular.
  • Link rather than repeat when there are many items: a table with data links (see annotations, links and drilldowns) to a per-item dashboard scales better than 100 repeated panels.
  • Avoid overlapping variables: repeating by a variable that is also a chained parent can cause long reload chains.
Python Stand-in: row repeat produces rows

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Repeat versus Dashboard data source

If each repeated panel runs its own query and the queries are heavy, consider one query feeding several panels with the Dashboard data source (see expressions and mixed queries) and filter inside each panel with a transformation. Repeat is convenient; sharing is cheaper.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. How wide is Grafana's dashboard grid?

    The grid has 24 columns; a panel with w: 12 is half the width.
  2. 2. What must be true of a variable to repeat a panel by it?

    A repeat makes one copy per selected value, so the variable needs multi-value or All.
  3. 3. What does $host contain inside one repeated copy?

    Each copy receives exactly one value so the same query works for every copy.
  4. 4. Why are collapsed rows good for performance?

    Collapsed rows skip their queries, so the dashboard loads fewer requests.

Summary

  • The dashboard grid is 24 columns wide; panels have x, y, w, h in gridPos.
  • Panels repeat by a multi-value variable with direction and max-per-row options; each copy sees one value.
  • Rows repeat too, giving a whole section per value; collapsed rows skip their queries.
  • Repeats are expanded at load time, and the template alone is stored.
  • For very many items, prefer a table with drilldown links over dozens of repeated panels.

Next: Annotations, Links and Drilldowns