Where to start First steps track · 15 stages
Linux Labs

Grafana — dashboards

4 min Grafana 11

Visualizing metrics and logs — data sources, dashboards, variables, alerts.

Cheat sheet

5 commands Printable version
  • systemctl status grafana-server service status
  • ss -tlnp | grep 3000 is the web UI listening
  • sudo grafana-cli admin reset-admin-password <new-password>
  • sudo grafana-cli plugins install grafana-piechart-panel
  • sudo systemctl restart grafana-server apply the plugin
  • data source → Prometheus → Save & Test
  • "No data" → check the query at :9090/graph and the time range
  • as code: /etc/grafana/provisioning/ + JSON dashboards in git

Overview

Grafana draws dashboards from data sources (Prometheus, Loki, Postgres, etc.). It doesn't store metrics itself — only queries and visualizes them. The web UI is on :3000.

The flow: a data source → a panel with a query (PromQL/SQL) → a dashboard → (optionally) alerts.

bash
systemctl status grafana-server
ss -tlnp | grep 3000              # is it listening (see ss)
# config: /etc/grafana/grafana.ini ; data/dashboards/plugins: /var/lib/grafana

Configuration

  1. Add data source → Prometheus → URL http://prometheus:9090 → Save & Test.
  2. New dashboard → panel → a PromQL query (rate(http_requests_total[5m])) → pick a visualization and units (Standard options → Unit).
  3. Dashboard variables ($instance, $job) — Settings → Variables → Query — for filtering by host/service.
  4. Explore (the compass icon on the left) — one-off queries without creating a panel.
bash
# plugins and maintenance via the CLI:
sudo grafana-cli plugins list-remote
sudo grafana-cli plugins install grafana-piechart-panel
sudo systemctl restart grafana-server
sudo grafana-cli admin reset-admin-password <new-password>

Recipes

1

Provisioning (as code)

Data sources, dashboards, and alerts are defined in files — reproducible, in git, not through clicking:

/etc/grafana/provisioning/datasources/*.yaml   # data sources
/etc/grafana/provisioning/dashboards/*.yaml    # paths to JSON dashboards
/etc/grafana/provisioning/alerting/*.yaml      # alerts

A dashboard is exported to JSON (Share → Export) and committed to the repository.

Troubleshooting

5

Panel: "No data"

  • Did the data source pass Save & Test?
  • Is the query correct? Check it in Prometheus itself first (:9090/graph).
  • Is the time range (top right) not "in the future"/too narrow?
  • Does the metric have the labels expected by $variable?

Data source: bad gateway / connection refused

Grafana can't reach the data source. Check the URL/port and that there's network connectivity (ss, firewall). From a container, use the service name, not localhost.

Forgot the admin password

sudo grafana-cli admin reset-admin-password <new-password> (or an environment variable at startup).

The dashboard disappeared after redeploying

If it wasn't provisioned, dashboards live in the database (/var/lib/grafana/grafana.db). Back it up, or keep dashboards as code (JSON in git plus provisioning).

502 behind a reverse proxy

If Grafana sits behind nginx/haproxy on a subpath, set root_url and serve_from_sub_path in grafana.ini, or links/login break.

See also

  • prometheus — Pull-based metrics collection — targets, PromQL, exporters, alerts.
  • system-monitoring — Load, CPU, memory, I/O — load average, top/htop, vmstat, iostat, free.
Loading…