Grafana Dashboards: Visualization and Alerting
· Pavan Y N · monitoring, observability, devops
Grafana is an open-source platform for querying, visualizing, and alerting on metrics, logs, and traces from many data sources. EduGeek explains how to run a current Grafana release, provision data sources and dashboards as code, build dashboards that use the modern JSON model, and set up Grafana Alerting, which replaced the legacy dashboard alerts and notification channels that older tutorials still describe.
As of October 2026 the current release is Grafana 13.2. Two earlier releases removed features that many guides still rely on: Grafana 11 removed legacy alerting entirely, and Grafana 12 removed AngularJS support, so Angular-based panels and plugins no longer load.
# Getting started with Grafana
## Installation
Grafana publishes two Docker images. grafana/grafana-enterprise is the edition the documentation recommends and includes all open-source features, and grafana/grafana is the open-source edition used below. Pin a version tag instead of latest.
Docker:
docker run -d \
--name=grafana \
-p 3000:3000 \
-v grafana-storage:/var/lib/grafana \
-e "GF_PLUGINS_PREINSTALL=grafana-clock-panel" \
grafana/grafana:13.2.4
The first sign-in uses the user admin with the password admin, and Grafana prompts for a new password. Plugins are installed with GF_PLUGINS_PREINSTALL, a comma-separated list that supports version pins such as grafana-clock-panel@3.2.4. The older GF_INSTALL_PLUGINS variable prints a deprecation warning in the image's start script. The grafana-piechart-panel plugin is unnecessary because a Pie chart panel is built in.
Docker Compose:
services:
grafana:
image: grafana/grafana:13.2.4
container_name: grafana
ports:
- "3000:3000"
environment:
GF_SECURITY_ADMIN_USER: admin
GF_SECURITY_ADMIN_PASSWORD__FILE: /run/secrets/grafana_admin_password
GF_USERS_ALLOW_SIGN_UP: "false"
GF_SERVER_ROOT_URL: https://grafana.example.com
GF_PLUGINS_PREINSTALL: grafana-clock-panel
secrets:
- grafana_admin_password
volumes:
- grafana-storage:/var/lib/grafana
- ./provisioning:/etc/grafana/provisioning:ro
- ./dashboards:/etc/grafana/dashboards:ro
restart: unless-stopped
secrets:
grafana_admin_password:
file: ./secrets/grafana_admin_password.txt
volumes:
grafana-storage:
Configuration options map to environment variables as GF_<SECTION>_<KEY> in uppercase, so [security] admin_user becomes GF_SECURITY_ADMIN_USER. Appending __FILE to a variable name makes the container read the value from a file, which keeps the admin password out of the Compose file and out of docker inspect. The admin password is applied only on first run, so changing the file later does not change an existing database. The top-level version: key that older Compose files start with is obsolete and is ignored by Docker Compose v2.
## Configuration as code
Grafana reads data source, dashboard, and alerting definitions from the provisioning directory at startup.
provisioning/datasources/datasources.yml:
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
uid: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
editable: false
jsonData:
timeInterval: 15s
queryTimeout: 60s
httpMethod: POST
- name: Loki
type: loki
uid: loki
access: proxy
url: http://loki:3100
editable: false
- name: CloudWatch
type: cloudwatch
uid: cloudwatch
editable: false
jsonData:
authType: default # use the instance, pod, or task IAM role
defaultRegion: us-east-1
Set an explicit uid so dashboards and alert rules can refer to a data source by a stable identifier. timeInterval should match the Prometheus scrape interval, because Grafana uses it when it computes $__rate_interval. For CloudWatch, authType: default uses the AWS SDK credential chain, which avoids putting access keys in provisioning files or environment variables.
Provisioning files can reference environment variables as $VAR or ${VAR}. Grafana replaces ${VAR} first, so a value that contains a literal $ can be truncated. Escape a literal dollar sign as $$. Variables work in provisioning configuration but not inside dashboard JSON files.
provisioning/dashboards/default.yml:
apiVersion: 1
providers:
- name: default
orgId: 1
folder: ''
type: file
disableDeletion: true
allowUiUpdates: false
updateIntervalSeconds: 30
options:
path: /etc/grafana/dashboards
foldersFromFilesStructure: true
With allowUiUpdates: false, the files on disk are the source of truth and the UI cannot save over them. foldersFromFilesStructure: true recreates the directory tree as Grafana folders, and it requires folder to stay empty. An updateIntervalSeconds value above 10 makes Grafana poll the path, while 10 or lower relies on filesystem events that some network mounts never emit.
# Dashboard creation
## The dashboard JSON model
A dashboard is a JSON document. File provisioning expects the dashboard model itself, with title at the top level. The {"dashboard": {...}, "overwrite": true} wrapper belongs to the HTTP API (POST /api/dashboards/db), and Grafana 13.2 rejects a wrapped file with the error Dashboard title cannot be empty.
dashboards/app-metrics.json:
{
"uid": "app-metrics",
"title": "Application Metrics",
"tags": ["application", "production"],
"timezone": "browser",
"schemaVersion": 41,
"version": 1,
"refresh": "30s",
"time": { "from": "now-6h", "to": "now" },
"templating": {
"list": [
{
"name": "datasource",
"label": "Data source",
"type": "datasource",
"query": "prometheus"
},
{
"name": "job",
"type": "query",
"datasource": { "type": "prometheus", "uid": "${datasource}" },
"query": "label_values(up, job)",
"refresh": 2,
"multi": true,
"includeAll": true
}
]
},
"annotations": {
"list": [
{
"name": "Restarts",
"datasource": { "type": "prometheus", "uid": "${datasource}" },
"expr": "changes(process_start_time_seconds{job=~\"$job\"}[1m]) > 0",
"tagKeys": "job,instance",
"titleFormat": "Process restarted",
"iconColor": "blue",
"enable": true
}
]
},
"panels": [
{
"id": 1,
"type": "timeseries",
"title": "Request rate",
"datasource": { "type": "prometheus", "uid": "${datasource}" },
"gridPos": { "x": 0, "y": 0, "w": 12, "h": 8 },
"targets": [
{
"refId": "A",
"expr": "sum by (job) (rate(http_requests_total{job=~\"$job\"}[$__rate_interval]))",
"legendFormat": "{{job}}"
}
],
"fieldConfig": {
"defaults": { "unit": "reqps" },
"overrides": []
}
},
{
"id": 2,
"type": "stat",
"title": "Error ratio",
"datasource": { "type": "prometheus", "uid": "${datasource}" },
"gridPos": { "x": 12, "y": 0, "w": 6, "h": 4 },
"targets": [
{
"refId": "A",
"expr": "sum(rate(http_requests_total{job=~\"$job\", status_code=~\"5..\"}[$__rate_interval])) / sum(rate(http_requests_total{job=~\"$job\"}[$__rate_interval]))"
}
],
"options": {
"reduceOptions": { "values": false, "calcs": ["lastNotNull"] },
"colorMode": "value",
"graphMode": "area",
"orientation": "auto"
},
"fieldConfig": {
"defaults": {
"unit": "percentunit",
"thresholds": {
"mode": "absolute",
"steps": [
{ "value": null, "color": "green" },
{ "value": 0.01, "color": "yellow" },
{ "value": 0.05, "color": "red" }
]
}
},
"overrides": []
}
},
{
"id": 3,
"type": "timeseries",
"title": "Response time (p95 and p99)",
"datasource": { "type": "prometheus", "uid": "${datasource}" },
"gridPos": { "x": 0, "y": 8, "w": 24, "h": 8 },
"targets": [
{
"refId": "A",
"expr": "histogram_quantile(0.95, sum by (le, job) (rate(http_request_duration_seconds_bucket{job=~\"$job\"}[$__rate_interval])))",
"legendFormat": "{{job}} p95"
},
{
"refId": "B",
"expr": "histogram_quantile(0.99, sum by (le, job) (rate(http_request_duration_seconds_bucket{job=~\"$job\"}[$__rate_interval])))",
"legendFormat": "{{job}} p99"
}
],
"fieldConfig": {
"defaults": {
"unit": "s",
"custom": {
"drawStyle": "line",
"lineInterpolation": "smooth",
"fillOpacity": 10
}
},
"overrides": []
}
}
]
}
Several details differ from older examples:
- →The
graphpanel type and itsyaxessetting belong to the removed Angular implementation. Usetimeseries, and set units underfieldConfig.defaults.unit. Grafana migrates old Graph panels to Time series, Bar chart, Bar gauge, or Histogram panels when it loads them, but the migration is not saved until the dashboard is saved, and provisioned dashboards cannot be saved from the UI. Copy the migrated JSON back into the provisioning source. - →Data source references are objects with a
typeand auid, not bare names. - →
$__rate_intervalreplaces fixed windows such as[5m]. It ismax($__interval + scrape_interval, 4 * scrape_interval), so a panel never uses a window shorter than four scrape intervals. - →The error ratio is a fraction between 0 and 1 and uses the
percentunitunit, which keeps thresholds and the displayed percentage consistent. - →
schemaVersionis managed by Grafana. Dashboards with an older value are migrated when they load, so hand-written files do not need to track the latest number. Build dashboards in the UI and export the JSON instead of writing it from scratch.
Current Grafana releases also define a v2 dashboard schema for dynamic dashboards, which uses a Kubernetes-style resource format (kind, apiVersion, metadata, spec). Classic JSON dashboards remain supported.
# Advanced dashboard features
## Variables
{
"templating": {
"list": [
{
"name": "environment",
"type": "custom",
"query": "Production : prod, Staging : staging, Development : dev",
"current": { "text": "Production", "value": "prod" }
},
{
"name": "namespace",
"type": "query",
"datasource": { "type": "prometheus", "uid": "prometheus" },
"query": "label_values(kube_pod_info{environment=\"$environment\"}, namespace)",
"refresh": 1,
"multi": true,
"includeAll": true
},
{
"name": "interval",
"type": "interval",
"query": "1m,5m,15m,1h",
"auto": true,
"auto_count": 30,
"auto_min": "10s"
}
]
}
}
A custom variable takes its options from the query string as a comma-separated list, where Production : prod pairs a display text with a value. For a query variable, refresh: 1 re-runs the query when the dashboard loads and refresh: 2 re-runs it whenever the time range changes. When a variable allows several values, Grafana joins the selection into a regular expression such as (web|api), so panels must use the regex matcher: {job=~"$job"}. With = the query matches nothing once two values are selected.
## Transformations
Transformations reshape query results before a panel renders them.
{
"transformations": [
{ "id": "merge", "options": {} },
{
"id": "organize",
"options": {
"excludeByName": { "__name__": true },
"indexByName": { "Time": 0, "job": 1, "Value": 2 },
"renameByName": { "job": "Service", "Value": "Requests/sec" }
}
},
{
"id": "calculateField",
"options": {
"mode": "binary",
"binary": {
"left": { "matcher": { "id": "byName", "options": "Value #A" } },
"operator": "/",
"right": { "matcher": { "id": "byName", "options": "Value #B" } }
},
"alias": "Ratio"
}
}
]
}
In binary mode, each side of the calculation is a field matcher or a fixed value, and the available operators are +, -, *, and /. Bare field-name strings from older dashboards are still converted on load.
# Alerting
## Grafana Alerting
Legacy alerting, which attached an alert block with conditions, frequency, and notifications to a graph panel, was removed in Grafana 11, and Grafana 10.4 was the last release that could migrate legacy alerts and notification channels. Grafana Alerting replaces both. The pieces fit together like this:
- →An alert rule combines one or more queries with expressions (Reduce, Math, Resample, or Classic condition), and one expression is marked as the alert condition.
- →Rules live in folders and evaluation groups. All rules in a group are evaluated together at the group's interval.
- →The pending period is how long the condition must stay breached before an alert moves from Pending to Firing. Optional settings cover keep firing for, no data handling, and error handling.
- →A rule creates one alert instance per time series. Labels on each instance drive routing.
- →Contact points define where notifications go, such as Slack, PagerDuty, email, or a webhook.
- →Notification policies form a tree that routes alert instances to contact points by label matching. The root is the default policy, which catches everything else.
- →Silences pause notifications once, and mute timings pause them on a schedule. Neither stops rule evaluation.
Rules, contact points, and policies can all be provisioned. The rule below fires when more than 5% of requests fail for five minutes.
provisioning/alerting/rules.yml:
apiVersion: 1
groups:
- orgId: 1
name: application
folder: Production alerts
interval: 1m
rules:
- uid: high-error-ratio
title: High error ratio
condition: C
for: 5m
noDataState: OK
execErrState: Error
labels:
severity: critical
annotations:
summary: More than 5% of requests are failing
data:
- refId: A
relativeTimeRange:
from: 600
to: 0
datasourceUid: prometheus
model:
refId: A
instant: true
expr: >-
sum(rate(http_requests_total{status_code=~"5.."}[5m]))
/ sum(rate(http_requests_total[5m]))
- refId: B
datasourceUid: __expr__
model:
refId: B
type: reduce
expression: A
reducer: last
- refId: C
datasourceUid: __expr__
model:
refId: C
type: threshold
expression: B
conditions:
- evaluator:
type: gt
params: [0.05]
provisioning/alerting/notifications.yml:
apiVersion: 1
contactPoints:
- orgId: 1
name: slack-alerts
receivers:
- uid: slack-alerts
type: slack
settings:
recipient: '#alerts'
url: $SLACK_WEBHOOK_URL
- orgId: 1
name: pagerduty-critical
receivers:
- uid: pagerduty-critical
type: pagerduty
settings:
integrationKey: $PAGERDUTY_INTEGRATION_KEY
severity: critical
policies:
- orgId: 1
receiver: slack-alerts
group_by: ['alertname', 'grafana_folder']
routes:
- receiver: pagerduty-critical
object_matchers:
- ['severity', '=', 'critical']
Grafana encrypts secret fields such as the Slack webhook URL and returns them as [REDACTED] from its API. Rules created in the UI cannot be recovered after deletion, so keep important rules in provisioning files, Terraform, or the Alerting API.
Grafana-managed rules suit alerts that combine several data sources or that non-Prometheus teams own. Rules written for Prometheus and routed through Alertmanager, as described in the Prometheus guide, keep alerting independent of Grafana's availability. Many teams use both.
# Complete dashboard example
## Kubernetes cluster overview
These queries work with the kubelet's cAdvisor metrics and kube-state-metrics. They belong in the expr field of each panel's query, using the same panel structure as the earlier dashboard.
| Panel | Query |
|---|---|
| Cluster CPU usage | sum(rate(container_cpu_usage_seconds_total{container!=""}[$__rate_interval])) / sum(kube_node_status_capacity{resource="cpu"}) |
| Cluster memory usage | sum(container_memory_working_set_bytes{container!=""}) / sum(kube_node_status_capacity{resource="memory"}) |
| Pods by namespace | sum by (namespace) (kube_pod_info) |
| Node readiness | kube_node_status_condition{condition="Ready", status="true"} |
Both usage queries return a fraction between 0 and 1, so use the percentunit unit. The label filter container!="" removes the pod-level aggregate series that cAdvisor also exports, which would otherwise double-count usage. Cluster fundamentals are covered in the Kubernetes guide.
# The Grafana stack and collectors
Grafana pairs with Loki for logs, Tempo for traces, and Mimir for long-term metrics, which together with Grafana (Loki, Grafana, Tempo, Mimir) make up the LGTM stack. Grafana Alloy is the collector for all of them. Alloy is a vendor-neutral distribution of the OpenTelemetry Collector with native Prometheus and OpenTelemetry pipelines, and it replaces two older agents that have reached end of life:
- →Grafana Agent (static mode, Flow mode, and the Agent Operator) reached end of life on November 1, 2025.
- →Promtail reached end of life on March 2, 2026.
Migration guides and a conversion command for existing configurations are in the Alloy documentation.
# Running Grafana in production
- →High availability: Grafana defaults to an embedded SQLite database, so an HA setup replaces it with a shared MySQL or PostgreSQL database and runs two or more nodes behind a load balancer. Sessions are stored in the database, so sticky sessions are not required. Grafana Alerting has its own HA mode, which evaluates every rule on every node and sends each notification once.
- →Authentication: use an external identity provider such as LDAP or an OAuth provider instead of local accounts, and disable sign-up.
- →Authorization: Grafana OSS includes the basic roles (Grafana administrator, organization administrator, Editor, Viewer, and No basic role). Fixed roles and custom roles are part of role-based access control (RBAC), which is available in Grafana Enterprise and Grafana Cloud.
- →Backups: back up the Grafana database and keep provisioning files and dashboard JSON in Git, which pairs well with a GitOps workflow.
- →Refresh rates:
min_refresh_intervalin the[dashboards]section prevents users from setting a refresh interval below the configured value. The default is five seconds.
# Best practices
## Dashboard design
- →Keep each dashboard focused on one service or question.
- →Use consistent layouts, naming, and units, and add panel descriptions.
- →Put the most important signals, such as rate, errors, and duration, at the top.
## Performance
- →Limit the number of panels and the length of time ranges that load by default.
- →Use
$__rate_intervaland recording rules for expensive queries. - →Choose refresh rates that match how fast the data changes, and avoid sub-minute refresh on large dashboards.
## Alerting
- →Alert on symptoms such as error ratio and latency, and send lower-urgency signals to chat instead of paging.
- →Include a summary, a dashboard link, and a runbook link in annotations.
- →Route by labels such as
severityandteamin notification policies.
## Organization
- →Use folders and tags, and manage them through provisioning.
- →Keep dashboards in version control, and review changes through pull requests.
- →Remove dashboards that nobody opens.
## Security
- →Run Grafana behind TLS, and keep secrets in files or environment variables rather than in provisioning YAML.
- →Review organization roles on a schedule, and enable audit logging where the edition supports it.
- →Update regularly, because plugin and core fixes ship in frequent releases.
# Key takeaways
- →Grafana 11 removed legacy dashboard alerts and notification channels, so alerts must be built with Grafana Alerting rules, contact points, and notification policies.
- →Grafana 12 removed AngularJS support, so
graphpanels become Time series panels and Angular-only plugins stop loading. - →File provisioning expects the plain dashboard model, while the
{"dashboard": ...}wrapper is only valid for the HTTP API. - →Data source references in dashboards and alert rules should use a stable
uid, and Prometheus panels should use$__rate_intervalinstead of fixed windows. - →Secrets belong in files or environment variables, using
GF_..._FILEvariables for container settings and$VARinterpolation in provisioning files. - →Grafana Alloy replaces Grafana Agent (end of life November 1, 2025) and Promtail (end of life March 2, 2026).
- →A highly available Grafana needs a shared MySQL or PostgreSQL database instead of the default SQLite file.
# Further reading
Test yourself: Grafana Dashboards assessment