Operations 6 min read

Master Grafana’s Stat Panel: Quick Setup, Styling, and JSON Configuration

This guide explains when to use Grafana's Stat panel, walks through creating and styling it in the browser, details orientation, text, color, and graph options, shows standard settings and value mappings, and provides a complete JSON configuration example for effective monitoring.

Linux Ops Smart Journey
Linux Ops Smart Journey
Linux Ops Smart Journey
Master Grafana’s Stat Panel: Quick Setup, Styling, and JSON Configuration

Introduction

In daily operations we constantly handle massive monitoring data. The Grafana Stat panel provides a concise “first‑glance” view of the most critical system metrics, enabling rapid perception and decision‑making.

When to Use a Stat Visualization

Quickly see key indicators such as the latest application health, high‑priority error counts, or total sales.

Display aggregated data like average service response time.

Highlight values that exceed normal thresholds for fast anomaly detection.

Creating a Stat Panel in the Browser

Create a new visualization.

Select the “Stat” type.

In Panel options set the panel title.

Stat Style Settings

Orientation : Controls placement of multiple stats (auto, horizontally, vertically). Default is auto.

Text mode : Determines text display (value, value and label, auto). Default is auto.

Color mode : Choose a color mode, typically “Background Gradient”.

Graph mode : Choose “none” for no trend line or “Area” for a trend.

Text alignment : Auto, center, etc.

Standard Options

Unit : Set the unit of the displayed value.

Decimals : Number of decimal places to keep.

Color scheme : Single color for single‑value panels or classic palette for multi‑value panels.

Legend Formatting and Value Mappings

Use Options.Legend to format the legend and Value mappings to map specific values to custom text and colors (e.g., 0 → “Abnormal” in red, 1 → “Normal” in green).

JSON Configuration Example

{
  "datasource": {
    "uid": "${datasource}"
  },
  "targets": [
    {
      "editorMode": "code",
      "expr": "node_memory_MemTotal_bytes{instance=~\"${instance}\"}",
      // Options.Legend
      "legendFormat": "{{instance}}",
      "refId": "A"
    }
  ],
  "fieldConfig": {
    "defaults": {
      "color": {
        // <Standard options>.<Color scheme>
        "mode": "palette-classic"
      },
      // <Standard options>.Decimals
      "decimals": 0,
      // <Standard options>.Unit
      "unit": "bytes",
      // <Value mappings>.<add Value mappings>
      "mappings": [
        {
          "options": {
            "0": {
              "color": "semi-dark-red",
              "text": "不正常"
            },
            "1": {
              "color": "semi-dark-green",
              "text": "正常"
            }
          },
          "type": "value"
        }
      ]
    }
  },
  "options": {
    // <Stat styles>.Orientation
    "orientation": "auto",
    // <Stat styles>.<Text mode>
    "textMode": "auto",
    // <Stat styles>.<Color mode>
    "colorMode": "background",
    // <Stat styles>.<Graph mode>
    "graphMode": "none",
    // <Stat styles>.<Text alignment>
    "justifyMode": "center"
  },
  // Panel position
  "gridPos": {
    "h": 11,
    "w": 12,
    "x": 0,
    "y": 0
  },
  // Panel title
  "title": "主机总内存",
  // Visualization type
  "type": "stat"
}

Conclusion

The Stat panel is a cornerstone of Grafana monitoring, presenting the most important system state in the simplest form. Proper configuration of thresholds, colors, and value mappings brings dashboards to life, allowing a single glance to reveal system health.

JSONtutorialGrafanaStat panel
Linux Ops Smart Journey
Written by

Linux Ops Smart Journey

The operations journey never stops—pursuing excellence endlessly.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.