Geavanceerd
Zoeken inHow-to-gidsen
Zo zoek je
  • Typ de taak in je eigen woorden (poort vinden, firewall openen, schijf vol) of plak een foutmelding tussen aanhalingstekens.
  • Kies "Snel antwoord" om alleen de commando's te zien, of een gebied om in één vakgebied te blijven.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

How-to 64Observability · Grafana

How to build a Grafana dashboard

A good dashboard answers one question fast: "is it OK, and if not, where?". Grafana turns Prometheus (and Loki, databases, cloud metrics) into graphs. This how-to connects Prometheus, imports a ready-made dashboard for servers in one minute, then builds your own panel with the right unit, thresholds and a server selector — and keeps the dashboard in Git so it is never lost.

  • 5 Lessen
  • 5 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

64.1

The quick answer

  1. Connections → Data sources → Add → Prometheus, URL http://127.0.0.1:9090 → Save & test.
  2. Dashboards → New → Import, ID 1860 ("Node Exporter Full") → choose the Prometheus data source → Import.
  3. For your own: Dashboards → New → Add visualization, choose Prometheus, paste a query, set the unit, Save.

64.2

Step by step

  1. Connect the data source (UI as above — or as code, so it is the same on every Grafana):
/etc/grafana/provisioning/datasources/prometheus.yml
apiVersion: 1
datasources:
  - name: Prometheus
    type: prometheus
    uid: prom
    url: http://127.0.0.1:9090
    isDefault: true
systemctl restart grafana-server
  1. Import a community dashboard for a quick start (Node Exporter Full = ID 1860). Look at it, then build your own small one — big imported dashboards are slow and hard to read.
  2. Your own panel — example "CPU used %" per server:
FieldValue
Query100 - avg by (instance) (rate(node_cpu_seconds_total{mode="idle", instance=~"$instance"}[$__rate_interval])) * 100
Legend{{instance}}
UnitPercent (0-100)
Min / Max0 / 100
Thresholds70 orange, 90 red

$__rate_interval picks a safe rate() window for the zoom level.

  1. A server selector (variable) — Dashboard settings → Variables → New:
FieldValue
Nameinstance
TypeQuery
Querylabel_values(node_uname_info, instance)
Multi-value, Include Allon

Use instance=~"$instance" in every query — one dashboard for all servers.

  1. Good dashboard rules:
  • Top row: Stat panels for the big answers (up/down, error %, free disk).
  • Below: time series for the details.
  • The right unit on every panel (bytes, %, seconds) — never raw numbers.
  • Few panels (about 6–12); one dashboard per question.
  1. Keep it in Git — Dashboard → Share/Export → Export as JSON (or the dashboard API), store the file, and load it with provisioning:
/etc/grafana/provisioning/dashboards/files.yml
apiVersion: 1
providers:
  - name: files
    folder: Servers
    type: file
    options:
      path: /var/lib/grafana/dashboards

64.3

Check that it worked

The dashboard loads in a few seconds, the server selector changes all panels, values match what you see on the server (top, df -h), and the JSON is in Git.

Commando's in deze les

64.4

Common problems

ProblemCauseFix
No dataWrong data source, wrong label, or a time range with no data.Run the query in Explore; check the labels in Prometheus.
Imported dashboard says Datasource ${DS_PROMETHEUS} was not foundThe import did not map the data source.Import again and choose the data source; or set uid in provisioning.
Graph is spiky or empty when zoomed outrate() window too small for the step.Use $__rate_interval.
The dashboard is slowToo many panels or heavy queries.Fewer panels, recording rules in Prometheus, shorter default time range.
Changes lost after a rebuildDashboards were only in Grafana's database.Provisioning from files in Git.
Everyone can edit production dashboardsDefault roles.Folder permissions: viewers for most people, editors for the team.

64.5

Go further

1Why use a dashboard variable like $instance?

One dashboard works for every server; you pick the server(s) at the top.

2How do you make sure a dashboard is never lost?

Export it as JSON into Git and load it with provisioning.

Alle commando's in dit hoofdstuk