Using Repeating Panels and Rows
1. Enabling Panel Repeat
| Property | Value | Description |
|---|---|---|
| repeat | variable |
Variable name to repeat the panel by |
| repeatDirection | h or v |
Horizontal (h) or vertical (v) repetition |
| maxPerRow | number |
Maximum panels per row when repeatDirection is h |
Example: Repeating a panel by a variable
{
"panels": [
{
"id": 1,
"type": "graph",
"repeat": "env",
"repeatDirection": "h",
"maxPerRow": 3
}
]
}
2. Setting Repeat Direction
| Property | Values | Description |
|---|---|---|
| repeatDirection | 'h' | 'v' |
Defines the direction in which panels repeat. 'h' for horizontal, 'v' for vertical. |
3. Configuring Max Per Row
| Property | Values | Description |
|---|---|---|
| maxPerRow | 1 to 12 |
Maximum number of panels to display per row in the dashboard layout |
Example: Setting maxPerRow in dashboard JSON
{
"panels": [
{
"id": 1,
"type": "graph",
"maxPerRow": 3
},
{
"id": 2,
"type": "stat",
"maxPerRow": 3
}
]
}
Note: The
maxPerRow property is used to control how many panels are displayed in a single row when the dashboard layout is adjusted. It does not affect the actual panel size or positioning, but rather how many panels are grouped together in a row.
4. Using Repeating Rows
Repeating rows in Grafana allow you to dynamically create multiple instances of a row based on a variable's values. This is particularly useful for creating dashboards that adapt to different contexts or data dimensions.
| Property | Description | Example |
|---|---|---|
| repeat | Defines the variable to repeat on | repeat: env |
| repeatDirection | Defines the direction of repetition (horizontal or vertical) | repeatDirection: h |
Example: Repeating Rows Based on Environment
{
"panels": [
{
"type": "row",
"repeat": "env",
"repeatDirection": "h",
"title": "Environment: $env"
}
]
}
Note: The variable
env must be defined in the dashboard variables. Each instance of the row will be created for each value in this variable.
5. Selecting Repeat Variable
| Variable | Type | Description |
|---|---|---|
| datasource | string |
Name of the data source to use for repeating |
| panel | string |
ID of the panel to repeat |
| template | string |
Template string for variable replacement |
Example: Using a Data Source Variable
{
"name": "datasource",
"type": "datasource",
"label": "Select Data Source",
"query": "prometheus"
}
Note: The selected data source variable will be used to dynamically populate the repeating panel with data from that source.
6. Handling Empty Repeat
| Property | Description | Default | Notes |
|---|---|---|---|
| repeat | Defines the variable to repeat over | None | Must be a valid variable name from the dashboard |
| repeatDirection | Direction to repeat panels | h |
v for vertical, h for horizontal |
| maxPerRow | Maximum panels per row (horizontal repeat) | None | Applies only to horizontal repeats |
Example: Empty Repeat Handling
{
"panels": [
{
"id": 1,
"type": "graph",
"repeat": "server",
"repeatDirection": "h",
"maxPerRow": 3
}
]
}
Note: When a repeated panel has no data, it will show as empty or display a "No data" message depending on the panel type.
7. Combining Repeat with Templates
Example: Using repeat variables in template variables
datasource: "Prometheus"
refresh: 1m
editable: true
hideControls: false
templating:
list:
- name: "instance"
label: "Instance"
description: "Select instance to monitor"
type: "query"
datasource: "Prometheus"
query: "label_values(up, instance)"
multi: true
includeAll: true
- name: "job"
label: "Job"
description: "Select job to monitor"
type: "query"
datasource: "Prometheus"
query: "label_values(up, job)"
multi: true
includeAll: true
- name: "repeat"
type: "constant"
value: "instance"
label: "Repeat by instance"
| Property | Description | Values | Notes |
|---|---|---|---|
| repeat | Template variable used to repeat panels | instance, job |
Must be a valid template variable name |
| repeatIteration | Current iteration value in repeat loop | instance1, instance2 |
Available in panel queries and expressions |
| repeatPanel | Reference to the repeated panel | panelId |
Used in expressions to reference repeated panel |
Note: The
repeat variable must be a template variable defined in the dashboard's templating.list section.Warning: Repeating panels with large datasets can impact dashboard performance. Consider using
maxDataPoints in queries to limit data.Key Points
- Repeat variables allow dynamic panel creation based on template values
- Use
repeatIterationto access current iteration in queries - Template variables must be defined in the dashboard's templating section
- Repeated panels inherit their configuration from the original panel
8. Styling Repeated Panels
| Property | Description | Values | Notes |
|---|---|---|---|
| panel.gridPos | Position of the panel in the grid | { x: number, y: number, w: number, h: number } |
Used for layout control in repeated panels |
| panel.styles | Styling rules for repeated panels | Array<object> |
Each object defines a style rule for matching conditions |
| panel.thresholds | Thresholds for conditional styling | Array<{ value: number, color: string }> |
Used in repeated panels to change appearance based on value |
Example: Styling Repeated Panels with Thresholds
{
"panels": [
{
"type": "graph",
"repeat": "instance",
"thresholds": [
{
"value": 80,
"color": "#FF9900"
},
{
"value": 95,
"color": "#E02F49"
}
]
}
]
}
Note: When using repeated panels, styling is applied to each instance based on the same rules and thresholds.
9. Limiting Repeat Count
When using repeating panels or rows in Grafana, you can limit the number of repetitions to prevent performance issues or UI clutter.
| Option | Values | Description |
|---|---|---|
| repeat | max |
Maximum number of repetitions allowed for a panel or row |
| repeatIteration | number |
Current iteration number in the repeat loop (read-only) |
Note: Setting a high
repeat value can lead to performance degradation in large dashboards. It's recommended to set a reasonable limit based on your data and dashboard requirements.
10. Debugging Repeat Issues
Example: Debugging repeated panel issues
// Check for variable evaluation errors
// In Grafana dashboard JSON, inspect variables
{
"panels": [
{
"type": "graph",
"targets": [
{
"expr": "rate(http_requests_total{job='${job}'}[5m])"
}
],
"gridPos": {
"x": 0,
"y": 0,
"w": 12,
"h": 8
}
}
]
}
| Issue | Description | Solution |
|---|---|---|
| Variable not expanding | Repeating panels fail to expand due to invalid variable syntax or missing variables. | Verify variable definitions in dashboard JSON and ensure all variables are properly set. |
| Empty panels appear | Repeating panels render but contain no data due to incorrect query or filter. | Check the query expression and ensure it returns valid data for each repeated instance. |
| Performance degradation | Too many repeated panels cause dashboard load delays or timeouts. | Limit the number of repeated panels using variable options or use maxDataPoints. |
Note: Use the
__dashboard variable to reference dashboard metadata in repeating panels.
Warning: Avoid deeply nested repeating panels as they can lead to exponential growth in panel count and performance issues.