Build a Grafana dashboard for Prometheus: a practical starting point
Connect Grafana to Prometheus, graph Linux host CPU and memory, add instance variables, and import dashboards with the right network, query, persistence and provisioning assumptions.
A query can return valid numbers while a dashboard still tells the wrong story. Per-core idle time is not host CPU usage, and a gauge configured to average a range is not showing its latest value. This guide takes Prometheus metrics through Grafana deployment, data-source setup, panels, variables, and a reusable dashboard.
1. Run Grafana with a network and a data volume
The example assumes an existing container named prometheus, with port 9090 reachable by peers on its network. It creates a new metrics network and a Grafana container. If those names already exist, adapt the configuration rather than creating conflicting resources.
docker network create metrics
docker network connect metrics prometheus
docker volume create grafana-data
docker run -d --name grafana --network metrics \
-p 127.0.0.1:3000:3000 \
--mount source=grafana-data,target=/var/lib/grafana \
grafana/grafana:13.3.0-ubuntu
The image is pinned to the 13.3.0 Ubuntu version listed on the official download page on November 5, 2026. Choose a verified version for your deployment; a digest can pin the image content more precisely. A floating latest tag is not a fixed release.
The user-defined network lets the containers resolve one another by name. Two independently started containers on Docker's default bridge do not automatically get prometheus name resolution. The volume retains Grafana's database and other data under /var/lib/grafana; reuse it when replacing the container. It does not persist Prometheus metrics. Grafana Docker installation · Docker bridge networks
Open http://localhost:3000. A fresh instance with unchanged administrator settings defaults to admin/admin and normally prompts for a password change. Reused volumes, preset credentials, or another authentication method change that assumption. This example publishes the port only on the host's loopback address; remote access needs a separately configured entry point.
2. Connect the Prometheus data source
Go to Connections → Data sources → Add data source → Prometheus. Menu names may vary by Grafana version.
- URL:
http://prometheus:9090fits the shared-network example when that endpoint serves HTTP. For another deployment, use an address reachable from the Grafana server.localhostinside the Grafana container means that container, not the Docker host or the reader's browser. - Authentication and TLS: Leave credentials empty only for a local endpoint that genuinely requires no authentication. Configure Basic Auth, token headers, certificate authorities, and server names as required by the endpoint. Disabling certificate verification is not a connection fix.
- Save & Test: Check connectivity, then verify that Prometheus is scraping the required metrics. A working data source does not mean host metrics already exist. Prometheus data-source configuration
3. Create CPU and memory panels
Choose Dashboards → New → Add visualization, then select the data source. The examples require Linux node_exporter, the relevant collectors, and successful Prometheus scrapes. Installing Grafana or Prometheus does not create these host metrics.
For a Time series panel, graph CPU usage:
100 - avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100
rate calculates each core's idle-time rate. Averaging by instance and subtracting from 100 gives the host's average non-idle percentage, rather than a line per core. The five-minute lookback is an example and needs sufficient scrape samples. If several jobs reuse the same instance, restrict the collection source before aggregating. Prometheus rate · node_exporter
- Set query type to Range for a trend over the selected time range.
- Use
{{instance}}as the legend to identify each instance. - Select Percent (0-100); the expression already produces percentage points on that scale.
- Name both the measurement and scope, such as “CPU usage — production cluster.” A title does not itself filter production data.
For a Gauge, use the complement of Linux available memory:
(1 - node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) * 100
This is a host-memory measure, not process or container utilization. Instant evaluates it once at the end of the selected time range. The end of a historical range is not now. If you use Range instead, explicitly choose a reducer such as Last or Last not null; Mean represents the range average. Sample freshness and missing data still matter.
Use percent units and, if appropriate, a fixed minimum and maximum of 0 and 100. Example thresholds are green as the base, yellow at 70, and red at 90: below 70, 70 to below 90, and at least 90. Those are illustrative display bands, not universal failure thresholds. Gauges and reductions
4. Filter instances with a variable
Add a variable while editing the dashboard. Older versions expose Settings → Variables → New; the current editor also has an Add variable entry.
- Name:
instance - Type: Query, with the Prometheus data source selected
- Query type: Label values
- Label:
instance; Metric:node_cpu_seconds_total
The deprecated Classic query form, label_values(node_cpu_seconds_total, instance), belongs to Grafana's variable editor. It is not a PromQL function you can submit directly to Prometheus. Prefer the Label values editor for new variables.
Reference $instance in panel queries. This example keeps the same average CPU-usage definition:
100 - avg by (instance) (rate(node_cpu_seconds_total{mode="idle", instance=~"$instance"}[$__rate_interval])) * 100
With Multi-value or Include All, Grafana interpolates a regular expression, so use =~ rather than the exact-match operator =. Grafana also replaces $__rate_interval before sending the query. Its calculation uses the query interval and configured scrape interval: the per-query Min step, if set, or the data-source scrape setting—not the panel's Min interval. It helps choose a rate window, but an incorrect setting or interrupted scrapes can still leave too few samples.
Only queries that reference the variable will filter. Add instance=~"$instance" to both memory-metric selectors if the gauge should follow the same selection. A dropdown does not automatically constrain every panel. Prometheus variables
5. Import a community dashboard carefully
The Grafana dashboard catalog provides importable templates. For example, use the Import entry to load Node Exporter Full, ID 1860, choose a revision and data source, then inspect its panels.
A successful import loads configuration; it does not establish metric coverage. Check the selected revision's node_exporter version, job names, labels, and collectors. Its page recommends systemd and processes because some panels use their metrics. Grafana and plugin compatibility can also affect rendering. When a chart is empty, inspect its query and collection configuration before removing or adapting it.
Keep the dashboard readable and affordable to query
- Separate audiences. Put SLO-oriented availability and error-rate overviews on the first page, with detail on drill-down pages. A wall of 200 charts is hard to use.
- Separate time settings. The dashboard range, refresh period, Prometheus scrape interval, and
ratelookback do different jobs. “Last hour, refresh every 30 seconds” is an example; choose settings for the data's update rate and query load. - Annotate deployments. An annotation helps compare a metric change with deployment timing. Temporal correlation still needs investigation before it becomes a causal explanation.
- Split by reading and loading cost. There is no universal six-to-eight-chart limit; organize the dashboard around what someone needs to read and how much work its queries perform.
Common questions
Will dashboard queries load Prometheus? Yes. Frequent refreshes, long ranges, high cardinality, and expensive expressions can all add work. There is no universal production rule that refreshes must be at least 30 seconds apart. Recording rules can precompute repeatedly used expressions in Prometheus, but they run fixed PromQL on a schedule and cannot directly use Grafana's $instance or $__rate_interval. They add their own compute and storage cost, so they are not mandatory for every long-range query. Recording rules
How do Grafana and Kibana differ? Grafana can visualize metrics, logs, traces, and other data through its data sources. Kibana works with Elasticsearch for document search, metrics, time-series analysis, and more. “Metrics versus logs” is too narrow a distinction. Guance's dashboards also organize views of collected data, which is useful when a trend needs a related investigation entry point. Collection, queries, and relevant fields still need configuration; adding a dashboard does not create its data. Grafana overview · Kibana analysis
How do I version dashboard configuration? Export/import JSON or use file provisioning. The latter needs both dashboard JSON and a provider YAML under /etc/grafana/provisioning/dashboards, with type: file and options.path pointing to a directory the Grafana server or container can actually read. Check mounts, permissions, and data-source UIDs. Mounting a dashboard folder alone does not create a provider. Git also needs a controlled sync/deployment process to become a GitOps workflow. Provisioned files can overwrite UI edits, so decide which is authoritative. Grafana provisioning
Contact us
Join the community
to join the community
Try Guance
Start online and pay only for what you use.
Get startedChoose a Guance plan
