Skip to main content

Working with Panels

1. Adding Panel to Dashboard

Example: Adding a new panel to a dashboard

{
  "dashboard": {
    "title": "My Dashboard",
    "panels": [
      {
        "id": 1,
        "type": "graph",
        "title": "CPU Usage",
        "targets": [
          {
            "expr": "rate(node_cpu_seconds_total{mode='idle'}[5m])",
            "legendFormat": "CPU Idle"
          }
        ]
      }
    ]
  }
}
Property Description Default Value
id Unique identifier for the panel Auto-generated
type Panel type (e.g., graph, table, stat) graph
title Title displayed on the panel Untitled Panel
targets Query definitions for data sources Empty array
Note: Panels can be added via the Grafana UI by clicking "Add Panel" or programmatically through the API.

2. Configuring Panel Title

Property Values Description
title string The text to display as the panel title. Supports variables and templating.
titleFontSize string Font size for the panel title (e.g., 16px, 1.2em).
titleColor string Color of the panel title (e.g., #ffffff, red).
titleBackground string Background color of the panel title area (e.g., #000000).

Example: Setting Panel Title

{
  "title": "CPU Usage Over Time",
  "titleFontSize": "18px",
  "titleColor": "#333333",
  "titleBackground": "#f5f5f5"
}

3. Adding Panel Description

Panel descriptions provide context and documentation directly within the panel, enhancing readability and usability for dashboard viewers.

Property Description Values Notes
description Panel description text string Supports markdown formatting

Example: Setting Panel Description

{
  "id": 1,
  "title": "CPU Usage",
  "description": "Real-time CPU usage statistics for the primary server."
}
Note: The description appears below the panel title in the dashboard view.

4. Selecting Visualization Type

Visualization Type Description Use Case Code Example
Graph Line or area chart for time-series data Monitor trends over time
{
  "targets": [
    {
      "expr": "rate(http_requests_total[5m])",
      "legendFormat": "{{method}} {{path}}"
    }
  ]
}
Bar Gauge Vertical or horizontal bar gauge showing progress toward a goal Display percentage completion or resource usage
{
  "targets": [
    {
      "expr": "100 * (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes)",
      "legendFormat": "Memory Available %"
    }
  ]
}
Stat Single value display with optional trend indicator Quick overview of key metrics
{
  "targets": [
    {
      "expr": "sum(http_requests_total)",
      "legendFormat": "Total Requests"
    }
  ]
}
Table Tabular data display with sorting and filtering Present detailed metric values in structured format
{
  "targets": [
    {
      "expr": "rate(http_requests_total[5m])",
      "legendFormat": "{{method}} {{path}}"
    }
  ],
  "transformations": [
    {
      "id": "organize",
      "options": {
        "excludeByName": {},
        "indexByName": {},
        "renameByName": {
          "Value": "Requests per Second"
        }
      }
    }
  ]
}
Heatmap Color-coded matrix for time-series data distribution Analyze frequency and intensity patterns over time
{
  "targets": [
    {
      "expr": "rate(http_requests_total[5m])",
      "legendFormat": "{{method}} {{path}}"
    }
  ],
  "transformations": [
    {
      "id": "timeSeries",
      "options": {}
    }
  ]
}

5. Resizing Panels

Property Values Description
panel.height auto, fixed Sets the height behavior of the panel. auto adjusts to content, fixed uses a set height.
panel.width auto, fixed Sets the width behavior of the panel. auto adjusts to content, fixed uses a set width.
gridPos.h number Defines the height of the panel in grid units (default is 3).
gridPos.w number Defines the width of the panel in grid units (default is 6).

Example: Setting Fixed Panel Size

{
  "gridPos": {
    "h": 4,
    "w": 8
  },
  "height": "fixed",
  "width": "fixed"
}
Note: Panel size is managed via the grid layout system. Adjusting gridPos.h and gridPos.w directly affects how the panel appears in the dashboard grid.

6. Positioning Panels

Property Values Description
gridPos { x: number, y: number, w: number, h: number } Defines the panel's position and size in the grid layout
x number Horizontal position in grid units (0-based)
y number Vertical position in grid units (0-based)
w number Width in grid units (default: 8)
h number Height in grid units (default: 4)

Example: Setting Grid Position

{
  "gridPos": {
    "x": 0,
    "y": 0,
    "w": 8,
    "h": 4
  }
}
Note: Grid units are based on a 24-column grid system. Each unit is approximately 100px wide.
Warning: Panels must not overlap. If two panels share the same grid space, one will be hidden.

7. Duplicating Panels

Panel duplication is a powerful feature in Grafana that allows you to quickly create copies of existing panels with minimal effort. This is particularly useful when you want to apply similar configurations or visualizations to different data sources or metrics.

Operation Description Steps
Duplicate Panel Duplicates a panel and its configuration
  1. Select the panel you want to duplicate
  2. Click the ... menu in the top-right corner of the panel
  3. Choose Duplicate from the dropdown menu
  4. The new panel will appear with the same configuration as the original

Example: Duplicating a Panel with Modified Query

// Original panel configuration
{
  "targets": [
    {
      "expr": "up",
      "legendFormat": "Up"
    }
  ]
}

// After duplication, modify the query to reflect a different metric
{
  "targets": [
    {
      "expr": "node_cpu_seconds_total",
      "legendFormat": "CPU Usage"
    }
  ]
}

8. Setting Panel Data Source

Property Description Values Notes
datasource Specifies the data source to use for panel queries string Must match a configured data source name in Grafana
targets Array of query targets to execute against the data source array Each target defines a query for the selected data source

Example: Panel with Prometheus Data Source

{
  "datasource": "Prometheus",
  "targets": [
    {
      "expr": "rate(http_requests_total[5m])",
      "legendFormat": "Requests per second"
    }
  ]
}
Note: The datasource field must reference a valid data source configured in Grafana, such as Prometheus, InfluxDB, or Elasticsearch.

9. Configuring Panel Time Override

Property Value Description
timeOverride string Overrides the panel's time range. Accepts values like now-1h, now-6h, etc.
timeShift string Shifts the time range by a specified duration (e.g., 1h, 30m). Can be used with timeOverride.
timeRange object Defines a custom time range with from and to properties in ISO 8601 format.

Example: Setting a Time Override

{
  "timeOverride": "now-2h",
  "timeShift": "1h"
}
Note: Time overrides are applied before any query execution and can be useful for comparing data over different time windows.
Link Type Description Usage Notes
Dashboard Link Links to another dashboard within the same Grafana instance dashboardUid, dashboardId Can pass variables to the target dashboard
URL Link Opens a URL in a new tab or window url, targetBlank Supports templating with variables
Panel Link Links to a specific panel within the same dashboard panelId, dashboardUid Useful for drill-down navigation
{
  "targets": [
    {
      "dashboardUid": "abc123",
      "name": "View Logs Dashboard"
    }
  ]
}
{
  "targets": [
    {
      "url": "https://example.com/logs?query=${__dashboard.name}",
      "targetBlank": true
    }
  ]
}

11. Setting Panel Transparency

Property Values Description
transparent true | false Controls whether the panel background is transparent. Defaults to false.

Example: Setting Panel Transparency

{
  "transparent": true
}

Was this article helpful?