Grafana Dashboard From Scratch: CPU, Memory, Disk and Network (Updated for Grafana 13)¶
PDF: Download this guide (PDF)
Overview¶
| Video | Grafana Dashboard: Monitor CPU, Memory, Disk and Network Traffic Using Prometheus and Node Exporter |
| Channel | Moss |
| Published | 18 Oct 2020, 26:03 long |
| Link | https://youtu.be/YUabB_7H710 |
| Assumes | Prometheus, node-exporter and Grafana are already running. Step 0 covers that if they are not |
| Tested on | Grafana 13.3.2, Prometheus 3.16.0, node-exporter 1.13.1, on Linux with Docker (3 Dec 2026) |
Core principle
Importing a ready-made dashboard is useful, but you learn more by building each panel and writing each query yourself (1:00).
The video was recorded in 2020 on Grafana 7. The queries still work, but almost every screen has moved. This guide follows the video's five panels in the same order and gives the clicks for Grafana 13. Items marked "Beyond the video" are additions: the updated screens, three improved queries, a tested Docker setup, phone alerts, and what to do before putting Grafana on the internet. They are not claims made by the presenter.
How the pieces fit¶
flowchart LR
host(["Linux host<br/>CPU, memory, disk, network"])
ne["node-exporter<br/>the gauges, port 9100"]
prom["Prometheus<br/>the logbook, port 9090"]
graf["Grafana<br/>the dashboard, port 3000"]
you(["Your browser"])
host --> ne
ne -->|"scraped every 15 s"| prom
prom -->|"PromQL queries"| graf
graf --> you
| Piece | Plain-English job |
|---|---|
| node-exporter | Reads the host's current numbers and shows them on a web page at /metrics (0:33) |
| Prometheus | Fetches that page on a schedule and stores every reading with a timestamp |
| Grafana | Asks Prometheus questions in a query language called PromQL and draws the answers |
Build roadmap¶
flowchart TB
s0["0: Stack running<br/>Beyond the video"]
s1["1: Look at the raw metrics<br/>and connect Grafana to Prometheus"]
s2["2: CPU utilization"]
s3["3: Memory usage"]
s4["4: Disk space used"]
s5["5: Disk space available"]
s6["6: Network traffic"]
s7["7: Arrange, save, export"]
s8["8: Alerts to your phone<br/>Beyond the video"]
s9["9: Lock it down<br/>Beyond the video"]
s0 --> s1 --> s2 --> s3 --> s4 --> s5 --> s6 --> s7
s7 -.-> s8
s7 -.-> s9
Prerequisites and tools¶
| Item | Purpose | Required? |
|---|---|---|
| A Linux machine (server, VM, or spare laptop) | The host you will monitor | Yes |
| Docker Engine with the Compose plugin | Runs the three programs in Step 0 | Yes, for Step 0 |
| SSH access to that machine | To run commands and to open Grafana safely | Yes |
| A browser on your own computer | To use Grafana | Yes |
| The ntfy app on your phone | Push alerts in Step 8 | Optional |
Skills assumed: you can edit a text file over SSH and run a command. No PromQL knowledge is needed; every query is given and explained.
Before you start: cautions¶
Prometheus and node-exporter have no login
Anyone who can reach ports 9090 or 9100 can read everything about your machine. Keep them on 127.0.0.1 (this machine only), as Step 0 does. Never forward those ports on your router.
- Change Grafana's
admin/admindefault before anything else. Step 0 sets a real password from the start. - Pin image versions.
latestcan change under you on the next pull. - The video hard-codes
job="jenkins-node"andinstance="localhost:9100"into every query (3:38). Those are names from the presenter's own setup. Copying them unchanged gives you empty panels.
What moved between the video and Grafana 13¶
Beyond the video. Use this table whenever the video shows a screen you cannot find.
| The video (Grafana 7, 2020) | Grafana 13 |
|---|---|
| Plus sign in the left bar, then Dashboard (2:34) | Dashboards in the left menu, then New and New dashboard. Or the + at the top right |
| Add new panel | Click Edit, then Add panel under the last panel (on an empty dashboard, the Panel tile in the Add pane). Then Configure visualization |
| "Graph" visualization | Time series. The old Graph panel has been removed |
| Query typed straight into the Metrics box | The query editor opens in Builder mode. Switch the toggle to Code to type a query |
| Chart type picked first | Run the query first. Grafana then shows Suggestions; click the first one, Time series |
| Legend field under the query | Under the query, open Options, set Legend to Custom, then type the template |
| Axes tab, Left Y, Unit (8:19) | Right-hand pane, Standard options, Unit |
| Panel title on the General tab | Right-hand pane, Panel options, Title |
| Apply, then save with the disk icon | Save at the top right saves the panel and the dashboard together. Back returns to the dashboard |
| Drag panels freely | New dashboards use Auto grid, which sizes panels for you. Pick Custom grid to drag and resize by hand |
| Export from the share menu | Export in the right-hand strip, then Export as code |
| Panel menu, Duplicate | Panel menu (three dots), More..., Duplicate |
Step-by-step¶
Each step lists what, how, why, common mistakes, and additions beyond the video.
Step 0: Get Prometheus, node-exporter and Grafana running¶
What: Start all three with one Docker Compose file, each reachable from this machine only.
Why: The video starts with everything already installed. This is the missing first step.
Watch: Not in the video.
Beyond the video
-
Make a folder and create three files in it.
compose.yml:# Prometheus + node-exporter + Grafana on one Linux host. # Every service uses the host's network and listens on 127.0.0.1 only. name: monitoring services: node-exporter: image: prom/node-exporter:v1.13.1 restart: unless-stopped network_mode: host pid: host command: - --path.rootfs=/host - --web.listen-address=127.0.0.1:9100 volumes: - /:/host:ro,rslave prometheus: image: prom/prometheus:v3.16.0 restart: unless-stopped network_mode: host command: - --config.file=/etc/prometheus/prometheus.yml - --storage.tsdb.path=/prometheus - --storage.tsdb.retention.time=30d - --web.listen-address=127.0.0.1:9090 volumes: - ./prometheus:/etc/prometheus:ro - prometheus-data:/prometheus grafana: image: grafana/grafana:13.3.2 restart: unless-stopped network_mode: host environment: GF_SERVER_HTTP_ADDR: 127.0.0.1 GF_SERVER_HTTP_PORT: "3000" GF_SECURITY_ADMIN_USER: admin GF_SECURITY_ADMIN_PASSWORD: ${GRAFANA_ADMIN_PASSWORD:?set it in .env} GF_USERS_ALLOW_SIGN_UP: "false" volumes: - grafana-data:/var/lib/grafana depends_on: - prometheus volumes: prometheus-data: grafana-data:prometheus/prometheus.yml:global: scrape_interval: 15s scrape_configs: - job_name: node static_configs: - targets: ["127.0.0.1:9100"].env, holding the Grafana password. Generate one and lock the file:printf 'GRAFANA_ADMIN_PASSWORD=%s\n' "$(openssl rand -base64 24)" > .env chmod 600 .env -
Start it:
docker compose up -d - Check all three are up:
docker compose ps -
Check Prometheus can reach node-exporter. This should print
"health":"up":curl -s 127.0.0.1:9090/api/v1/targets | grep -o '"health":"[a-z]*"' -
Check nothing is exposed. Every line must start with
127.0.0.1:sudo ss -tlnp | grep -E ':(3000|9090|9100)\b' -
Open Grafana from your own computer through an SSH tunnel. Run this on your computer, leave it open, then browse to
http://localhost:3000:ssh -N -L 3000:127.0.0.1:3000 you@your-serverLog in as
adminwith the password from.env.
Why the host network
- node-exporter can only see the machine's real network cards from the host's own network. Inside a normal Docker network it reports its own virtual
eth0, and the network panel in Step 6 shows the wrong thing. - The node-exporter project's own Docker instructions use the host network and host PID namespace for this reason.
- Once node-exporter is on the host network, Prometheus has to reach the host. If you run a firewall such as UFW that denies incoming traffic, it also blocks containers on a Docker network from reaching host ports. Putting all three on the host network at
127.0.0.1avoids both problems without opening anything.
Common mistakes
- Leaving out
--web.listen-address. The default is every network card, not just this machine. - Using
latesttags, then finding the stack changed after a routine pull. - Running
docker compose down -v. The-vdeletes your stored history.
Step 1: Look at the raw metrics and connect Grafana to Prometheus¶
What: See the page node-exporter publishes, then tell Grafana where Prometheus is.
Why: Every panel you build is a question about the numbers on that page. Seeing it once makes the queries less mysterious (1:59).
Watch: 1:45
How to do it
- Look at the metrics page. On the server run
curl -s 127.0.0.1:9100/metrics | less. Each line is a metric name, optional labels in braces, and a value. - Find one you will use. Search for
node_cpu_seconds_total. You will see one line per CPU core per mode (user,system,idleand so on).
Beyond the video: add the data source in Grafana 13
The video's Grafana already had Prometheus connected (3:01). On a new install:
- In the left menu open Connections, then Data sources, then Add data source.
- Pick Prometheus.
- In Prometheus server URL enter
http://127.0.0.1:9090. - Scroll to the bottom and click Save & test. You want the green "Successfully queried the Prometheus API."

Common mistakes
- Typing
localhost:9090withouthttp://. - Using the server's LAN address. Prometheus only listens on
127.0.0.1, so that address refuses the connection.
Reading a metric line
| Part | Example | Meaning |
|---|---|---|
| Name | node_cpu_seconds_total |
What is measured. The ending tells you the unit (_seconds, _bytes) and _total marks a counter that only goes up |
| Labels | {cpu="0",mode="user"} |
Which one. Labels are how you filter and group |
| Value | 1234.56 |
The reading right now |
Prometheus adds two labels of its own to everything: job (the job_name in prometheus.yml) and instance (the target address).
Step 2: CPU utilization¶
What: A chart of how busy the CPU is, split by the kind of work.
Why: A pegged CPU is the first thing to rule out when a machine feels slow.
Watch: 1:45
The query, built up the way the video does it
| Stage | Query | What you see |
|---|---|---|
| 1. The raw counter (3:38) | node_cpu_seconds_total{mode!="idle"} |
Lines that climb forever. It is a counter of seconds since boot |
| 2. Turn it into a rate (4:42) | rate(node_cpu_seconds_total{mode!="idle"}[$__rate_interval]) |
Seconds of CPU used per second, per core |
| 3. Average the cores (6:04) | avg without (cpu) (rate(node_cpu_seconds_total{mode!="idle"}[$__rate_interval])) |
One line per mode for the whole machine, between 0 and 1 |
Stage 3 matters on any machine with more than one core. Without the average, four busy cores would read as 400 percent (7:13).
How to do it in Grafana 13
-
Start a dashboard. In the left menu click Dashboards, then New, then New dashboard.

-
Add a panel. In the Add pane on the right, click the Panel tile. A "New panel" box appears; click Configure visualization inside it.
- Switch to typing mode. Under the chart, next to Run queries, change Builder to Code.
- Type the stage 3 query and click Run queries.
-
Pick the chart type. The right-hand pane now shows Suggestions. Click the first one, Time series.

-
Clean up the legend. Under the query, open Options. Set Legend to Custom and type
{{mode}}. Each line is now nameduser,system,iowaitand so on (7:47). -
Set the unit. In the right-hand pane scroll to Standard options. Click Unit, type
percent, and choose Misc / Percent (0.0-1.0) (8:19).
-
Name the panel. At the top of the right-hand pane, under Panel options, set Title to
CPU utilization. -
Save. Click Save at the top right, give the dashboard a title such as
Host resource usage, and click Save (8:41). Then click Back to return to the dashboard.
Common mistakes
- Charting the raw counter and reading the endless climb as a problem.
- Choosing Percent (0-100). The query returns 0 to 1, so that unit shows a fully busy CPU as "1%".
- Forgetting the parentheses around the
rate(...)when addingavg without (cpu). The video hits this error too (6:40).
Beyond the video
- Use
rate, notirate. The video usesirate(...[1m])for sharper detail (4:42).iratelooks only at the last two samples in the window, so when you zoom out to a day most of the data is skipped and short spikes appear or vanish at random. Prometheus's documentation recommendsratefor anything that is not a fast-moving, zoomed-in graph. - Use
$__rate_interval, not a fixed[1m]. It is a Grafana variable that picks a safe window for the current zoom level and scrape interval. A fixed window that is too short for the scrape interval returns nothing at all. - Drop the hard-coded
jobandinstance. With one machine they add nothing. With several, use a dashboard variable instead (see "Going further"). - Want one number instead of seven lines?
1 - avg(rate(node_cpu_seconds_total{mode="idle"}[$__rate_interval]))is total CPU use.
Step 3: Memory usage¶
What: One panel with four lines: used, buffers, cached and free memory.
Why: Linux uses spare memory as disk cache on purpose. Seeing the four parts stops you from mistaking a healthy cache for a memory shortage.
Watch: 9:04
How to do it in Grafana 13
- Add another panel. On the dashboard click Edit at the top right, then Add panel under the last panel. A "New panel" box appears; click Configure visualization inside it.
- Switch to Code and enter the first query. Set its legend (Options, Legend, Custom) to
Used. -
Add three more queries. Click Add query under the first one for each. Every query needs Code mode and its own custom legend.
Legend Query Usednode_memory_MemTotal_bytes - node_memory_MemAvailable_bytesBuffersnode_memory_Buffers_bytesCachednode_memory_Cached_bytesFreenode_memory_MemFree_bytes -
Click Run queries, then choose the Time series suggestion.
- Set the unit. Standard options, Unit, type
bytes, choose Data / bytes(IEC) (12:03). The axis now reads in GiB. - Title it
Memory usageand Save.
Common mistakes
- Reading a small "Free" number as trouble. Free means untouched. Cached memory is given back the moment a program needs it.
- Setting the unit to bytes(SI). Memory is counted in powers of 1024, which is the IEC choice.
Beyond the video
- A better "used". The video computes used memory as total minus free, cached and buffers (9:36 to 11:18). The Linux kernel publishes
MemAvailablefor exactly this purpose: its own estimate of how much memory programs could still get without swapping. Total minus available is the number to watch and to alert on. On the test machine the two methods differed by about half a gigabyte. - The video's version, if you want to compare:
node_memory_MemTotal_bytes - node_memory_MemFree_bytes - node_memory_Cached_bytes - node_memory_Buffers_bytes. - To see memory as a share instead:
1 - node_memory_MemAvailable_bytes / node_memory_MemTotal_byteswith the unit Percent (0.0-1.0).
Step 4: Disk space used¶
What: Used space on each real disk, over time.
Why: A full disk stops databases and containers without warning. A rising line gives you days of notice.
Watch: 14:16
How to do it in Grafana 13
- Add a panel as in Step 3 (Edit, Add panel, Configure visualization) and switch to Code.
-
Enter the query:
node_filesystem_size_bytes{fstype=~"ext4|xfs|btrfs|vfat"} - node_filesystem_avail_bytes{fstype=~"ext4|xfs|btrfs|vfat"} -
Legend: Custom,
{{mountpoint}}. - Run queries, choose Time series.
- Unit: Data / bytes(IEC) (17:00).
- Title it
Disk space usedand Save.
Common mistakes
- Leaving out the filter. You get a line for every temporary and virtual filesystem on the machine.
- Naming the panel "available" when it shows "used". The video does this and corrects it (18:00).
Beyond the video
- Filter by filesystem type, not device name. The video excludes devices it does not want one by one: loop devices,
tmpfs,nsfsandgvfsd-fuse(15:18 to 16:10). That list is different on every machine. Naming the real disk formats you do want (ext4,xfs,btrfs,vfat) works everywhere. Addzfsor others if you use them. - Legend by mount point.
/and/bootmean more than/dev/nvme0n1p2. - On btrfs each subvolume shows up as its own line with the same numbers. Narrow it with
mountpoint="/"inside the braces. availis the space ordinary programs can use.node_filesystem_free_bytesalso counts blocks reserved for root, so it reads higher than what you can really write.
Step 5: Disk space available¶
What: The other half: space left on each real disk.
Why: "Available" is the number that hits zero when things break, so it is the one to alert on.
Watch: 18:24
How to do it in Grafana 13
- Add a panel, Configure visualization, switch to Code.
- Enter the query:
node_filesystem_avail_bytes{fstype=~"ext4|xfs|btrfs|vfat"} - Legend: Custom,
{{mountpoint}}. Unit: Data / bytes(IEC). - Title it
Disk space availableand Save.
Common mistakes
- Using different filters in the used and available panels, so the two do not add up.
Beyond the video
- A faster way to make this panel: click Edit, open the menu on "Disk space used" (the three dots), choose More... and then Duplicate. Edit the copy's query and title.
- For a single "how full" number per disk:
1 - node_filesystem_avail_bytes{fstype=~"ext4|xfs|btrfs|vfat"} / node_filesystem_size_bytes{fstype=~"ext4|xfs|btrfs|vfat"}with the unit Percent (0.0-1.0). A Gauge or Bar gauge visualization suits it better than a line.
Step 6: Network traffic¶
What: Download and upload speed for each network card.
Why: It shows backups, updates and runaway uploads at a glance, and whether a slow app is a network problem.
Watch: 21:21
How to do it in Grafana 13
- Add a panel, Configure visualization, switch to Code.
-
Enter two queries (use Add query for the second), each with a custom legend:
Legend Query {{device}} receiverate(node_network_receive_bytes_total{device!~"lo|veth.*|docker.*|br-.*"}[$__rate_interval]) * 8{{device}} transmitrate(node_network_transmit_bytes_total{device!~"lo|veth.*|docker.*|br-.*"}[$__rate_interval]) * 8 -
Run queries, choose Time series.
- Unit: Standard options, Unit, type
bits, choose Data rate / bits/sec(SI). - Title it
Network trafficand Save.
Common mistakes
- Seeing only
loandeth0when the machine has Wi-Fi or other cards. node-exporter is not on the host network; go back to Step 0. - Mixing up bits and bytes. Internet speeds are quoted in bits per second. The counters are in bytes, hence the
* 8.
Beyond the video
- A units slip in the video. The presenter says "kilobits per second" and picks kilobytes per second (24:08), but the query returns plain bytes per second. The axis is therefore 1,000 times too high. Multiplying by 8 and choosing bits/sec gives numbers that match your internet plan.
rateand$__rate_intervalreplace the video'sirate(...[5m])(22:09), for the reasons in Step 2.- Hide the plumbing. The
device!~filter removes the loopback device and the virtual cards Docker creates, which otherwise bury the real ones. The video has no containers on its VM, so it does not need this. - Upload below the line. Put a minus sign in front of the transmit query (
-rate(...) * 8) and download draws above zero with upload below. Many people find that easier to read.
Step 7: Arrange, save, and export¶
What: Lay the five panels out, save, and get a copy of the dashboard as a file.
Why: The file is your backup, and it is how you move the dashboard to another Grafana.
Watch: 24:58
How to do it in Grafana 13
- Arrange. Click Edit. New dashboards use Auto grid, which tiles the panels evenly. To place them by hand as the video does (18:24), click the gear icon in the right-hand strip and under Layout choose Custom. Then drag panels by their title and resize from the bottom-right corner.
- Set a default time range and refresh. Pick Last 1 hour in the time picker and 30s in the refresh menu beside it, then Save. The save drawer lists what changed; tick any "Update default" box it offers so the new settings stick.
- Export. Click Export in the right-hand strip (the download icon), then Export as code, then Download file. Keep the file somewhere other than the server. The video promises this export at the end (25:26).

The finished dashboard, ready to import
The dashboard built for this guide is in host-resource-usage.json. To use it: Dashboards, New, Import dashboard, then upload the file and click Import. It has a Data source picker at the top, so it works with whatever your Prometheus connection is called.
The presenter's original 2020 export is at moss-n/Grafana-Dashboards. It uses the old Graph panel and the jenkins-node job name, so expect to edit it after import.
Common mistakes
- Closing the browser tab without saving. Grafana warns you, but panels live only in the browser until you click Save.
- Keeping the only copy of a dashboard inside Grafana.
Beyond the video
- Save the JSON in git. Grafana can also load dashboards from files on start-up (called provisioning), which makes the whole setup rebuildable from a folder.
- Do not skip ready-made dashboards entirely. Once you understand these five panels, import Node Exporter Full (ID 1860). It has more than a hundred panels built on the same metrics, and you can now read its queries.
Step 8: Alerts to your phone¶
What: Have Prometheus watch the same metrics and push a notification when something is wrong.
Why: Nobody watches a dashboard all day. A dashboard explains a problem; an alert tells you there is one.
Watch: Not in the video.
Beyond the video
-
Write the rules. Create
prometheus/rules/alerts.yml:groups: - name: host rules: - alert: DiskSpaceLow expr: | (1 - node_filesystem_avail_bytes{fstype=~"ext4|xfs|btrfs|vfat"} / node_filesystem_size_bytes{fstype=~"ext4|xfs|btrfs|vfat"}) * 100 > 85 for: 10m annotations: summary: "Disk {{ $labels.mountpoint }} is {{ $value | printf \"%.0f\" }}% full" - alert: MemoryHigh expr: (1 - node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) * 100 > 90 for: 10m annotations: summary: "Memory has been {{ $value | printf \"%.0f\" }}% used for 10 minutes" - alert: TargetDown expr: up == 0 for: 2m annotations: summary: "Prometheus cannot reach {{ $labels.job }}"for: 10mmeans the condition must hold for ten minutes before the alert fires, so short blips are ignored. Notice the expressions are the queries from Steps 3 to 5 with a threshold added. -
Tell Prometheus about the rules and about Alertmanager. Add to
prometheus/prometheus.yml:rule_files: - /etc/prometheus/rules/*.yml alerting: alertmanagers: - static_configs: - targets: ["127.0.0.1:9093"] -
Pick a private ntfy topic. ntfy is a free push-notification app. A topic name works like a password: anyone who knows it can read your alerts. Make a long random one and store the address in a file:
mkdir -p alertmanager printf 'https://ntfy.sh/myserver-%s?template=alertmanager' "$(openssl rand -hex 12)" > alertmanager/ntfy-url chmod 644 alertmanager/ntfy-urlThe
?template=alertmanagerending tells ntfy to turn Alertmanager's raw data into a readable message. -
Configure Alertmanager. Create
alertmanager/alertmanager.yml:route: receiver: ntfy group_by: [alertname] group_wait: 30s repeat_interval: 4h receivers: - name: ntfy webhook_configs: - url_file: /etc/alertmanager/ntfy-url send_resolved: true -
Add Alertmanager to
compose.ymlunderservices:, then rundocker compose up -d:alertmanager: image: prom/alertmanager:v0.35.1 restart: unless-stopped network_mode: host command: - --config.file=/etc/alertmanager/alertmanager.yml - --storage.path=/alertmanager - --web.listen-address=127.0.0.1:9093 - --cluster.listen-address= volumes: - ./alertmanager:/etc/alertmanager:roThe empty
--cluster.listen-address=matters. Without it Alertmanager opens a second port on every network card. -
Reload Prometheus:
docker compose kill -s SIGHUP prometheus - Subscribe on your phone. Install the ntfy app, tap +, and enter the topic name (the part of the address between
ntfy.sh/and?). -
Send a test and wait about 30 seconds:
curl -H 'Content-Type: application/json' 127.0.0.1:9093/api/v2/alerts \ -d '[{"labels":{"alertname":"TestAlert"},"annotations":{"summary":"Test, nothing is wrong."}}]'
Common mistakes
- Never testing. An alert path you have not seen deliver is a guess.
- Putting the topic address in a file you commit to git.
- Expecting an alert when the whole machine or its internet is down. The machine cannot report its own death; that needs a check from somewhere else.
For a laptop used as a server
A laptop's battery is a built-in UPS, and node-exporter reports it. Check what your machine offers with curl -s 127.0.0.1:9100/metrics | grep -E 'node_power_supply|node_hwmon_temp_celsius', then add rules such as:
- alert: OnBatteryPower
expr: node_power_supply_online == 0
for: 1m
annotations:
summary: "AC power is out; running on battery"
- alert: CpuTemperatureHigh
expr: max(node_hwmon_temp_celsius{chip=~".*coretemp.*"}) > 85
for: 5m
annotations:
summary: "CPU has been at {{ $value | printf \"%.0f\" }} °C for 5 minutes"
The chip label differs between machines (Intel CPUs report as coretemp, AMD as k10temp). Use the name your own metrics page shows. The same two metrics make good dashboard panels: battery charge is node_power_supply_capacity.
Step 9: Lock it down before anyone else can reach it¶
What: The checks to make before Grafana is reachable from anywhere but the machine itself.
Why: The video runs everything on localhost and never discusses access. A monitoring stack describes your whole server to whoever can read it.
Watch: Not in the video.
Beyond the video
- Keep Prometheus, node-exporter and Alertmanager private, always. They have no login. Only Grafana should ever be shared.
- Prefer private access. The SSH tunnel from Step 0 or a private network such as Tailscale exposes nothing to the internet.
-
If you do publish Grafana (through a reverse proxy or a Cloudflare Tunnel), set these on the grafana service first:
GF_SERVER_ROOT_URL: https://grafana.example.com GF_SECURITY_COOKIE_SECURE: "true" GF_AUTH_ANONYMOUS_HIDE_VERSION: "true" GF_METRICS_ENABLED: "false"Setting What it prevents ROOT_URLBroken links and redirects behind a proxy COOKIE_SECUREThe login cookie being sent over plain HTTP HIDE_VERSIONStrangers reading your exact Grafana version before logging in METRICS_ENABLED: falseGrafana's own /metricspage, which needs no login by default -
Give other people their own accounts with the Viewer role (Administration, Users and access, Users, New user). Never share the admin password.
- Keep Grafana updated. It is the one piece facing other people.
Common mistakes
- Publishing port 3000 straight from the router with the default password still set.
- Routing Prometheus through the same proxy "just for a minute".
- Turning on secure cookies and then wondering why the plain-HTTP SSH tunnel stops keeping you logged in in some browsers. Use the HTTPS address once you have one.
Query reference: the video's version and the updated one¶
| Panel | The video (2020) | Updated | Why |
|---|---|---|---|
| CPU | avg without(cpu) (irate(node_cpu_seconds_total{job="jenkins-node",instance="localhost:9100",mode!="idle"}[1m])) |
avg without (cpu) (rate(node_cpu_seconds_total{mode!="idle"}[$__rate_interval])) |
rate is stable when zoomed out; the interval adapts; no hard-coded names |
| Memory used | MemTotal - MemFree - Cached - Buffers |
node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes |
The kernel's own estimate of usable memory |
| Disk used | node_filesystem_size_bytes{device!~"/dev/loop.*",device!~"tmpfs\|nsfs",device!="gvfsd-fuse"} - node_filesystem_avail_bytes |
node_filesystem_size_bytes{fstype=~"ext4\|xfs\|btrfs\|vfat"} - node_filesystem_avail_bytes{fstype=~"ext4\|xfs\|btrfs\|vfat"} |
Name what you want instead of excluding what you do not |
| Disk available | node_filesystem_avail_bytes{...same exclusions...} |
node_filesystem_avail_bytes{fstype=~"ext4\|xfs\|btrfs\|vfat"} |
Same |
| Network | irate(node_network_receive_bytes_total{...}[5m]), unit kilobytes/sec |
rate(node_network_receive_bytes_total{device!~"lo\|veth.*\|docker.*\|br-.*"}[$__rate_interval]) * 8, unit bits/sec |
Correct units; hides virtual cards |
Using the dashboard day to day¶
Beyond the video.
- Change the time range first. "Last 6 hours" to investigate now, "Last 7 days" to spot a slowly filling disk.
- Drag across a spike to zoom in. Double-click the chart to zoom back out.
- Click a legend name to show only that line. Ctrl-click (Cmd-click on a Mac) adds more.
- Press
vwith the pointer over a panel to view it full screen. Escape returns. - Use Explore for one-off questions. The compass icon in the left menu lets you type a metric name and chart it without building anything.
- Star the dashboard and set it as your home page under your profile, Preferences, Home Dashboard.
Going further¶
Beyond the video.
| Next step | How |
|---|---|
| Monitor several machines from one dashboard | Add each to prometheus.yml as another target. In the dashboard add a Variable of type Query with label_values(node_uname_info, instance), name it instance, and add instance="$instance" inside the braces of every query |
| One number at a glance | Use the Stat or Gauge visualization with the percentage versions of the queries |
| Per-container numbers | Add cAdvisor as a fourth service and a second scrape job |
| Rebuild from files | Provision the data source and dashboards from YAML and JSON so a fresh Grafana comes up complete |
Troubleshooting¶
| Symptom | Likely cause | Fix |
|---|---|---|
| Panel says "No data" | Copied job="jenkins-node" from the video, or a typo in a label |
Remove the job and instance filters; check names on the /metrics page |
| Target shows DOWN in Prometheus | node-exporter not running, or wrong address in prometheus.yml |
docker compose ps; the target must be 127.0.0.1:9100 |
| "Save & test" fails on the data source | Wrong URL | Use http://127.0.0.1:9090 exactly |
| CPU line only ever climbs | Charting the raw counter | Wrap it in rate(...[$__rate_interval]) |
| CPU reads a few percent when the machine is busy | Unit set to Percent (0-100) | Choose Percent (0.0-1.0) |
| Chart is empty when zoomed in tightly | Fixed range like [1m] shorter than two scrapes |
Use $__rate_interval |
Network panel shows only lo and eth0 |
node-exporter is inside a Docker network | Run it with network_mode: host as in Step 0 |
| Dozens of disk lines | No filesystem filter | Add fstype=~"ext4\|xfs\|btrfs\|vfat" |
| Cannot find "Add panel" | Not in edit mode | Click Edit at the top right first |
| Cannot type a query | Editor is in Builder mode | Switch the toggle to Code |
| No phone alert arrives | Not subscribed to the exact topic, or Prometheus not reloaded | Re-check the topic name; docker compose kill -s SIGHUP prometheus; send the test alert |
| Other containers cannot reach node-exporter | Host firewall blocks container-to-host traffic | Keep everything on the host network at 127.0.0.1, as in Step 0 |
Video timestamps¶
| Time | Chapter | Link |
|---|---|---|
| 0:00 | Introduction | https://youtu.be/YUabB_7H710?t=0 |
| 1:45 | CPU metric | https://youtu.be/YUabB_7H710?t=105 |
| 9:04 | Memory usage | https://youtu.be/YUabB_7H710?t=544 |
| 14:16 | Disk usage | https://youtu.be/YUabB_7H710?t=856 |
| 21:21 | Network traffic | https://youtu.be/YUabB_7H710?t=1281 |
| 25:07 | Conclusion | https://youtu.be/YUabB_7H710?t=1507 |
Final checklist¶
- Three containers up, all listening on
127.0.0.1only — Step 0 - Grafana password set in
.env;admin/admindoes not work — Step 0 - Prometheus target shows UP — Step 0
- Data source saved with the green success message — Step 1
- CPU panel reads as a percentage, one line per mode — Step 2
- Memory panel shows used, buffers, cached and free in GiB — Step 3
- Disk used and available show only real disks — Steps 4 and 5
- Network panel shows your real network card in bits per second — Step 6
- Dashboard saved and exported as JSON to somewhere off the server — Step 7
- Test alert received on your phone — Step 8
- Nothing but Grafana reachable by anyone else — Step 9
Sources¶
- Grafana Dashboard: Monitor CPU, Memory, Disk and Network Traffic Using Prometheus and Node Exporter — Moss on YouTube
- Host Resource Usage Example (dashboard JSON) — moss-n on GitHub
- Prometheus query functions (rate, irate) — Prometheus docs
- Grafana: use $__rate_interval — Grafana docs
- node_exporter README (Docker) — Prometheus project
- Monitoring Linux host metrics with the Node Exporter — Prometheus docs
- The /proc filesystem (MemAvailable) — Linux kernel docs
- Prometheus metric and label naming — Prometheus docs
- Create a dashboard — Grafana docs
- Import dashboards — Grafana docs
- Docker: packet filtering and firewalls — Docker docs
- Grafana: configure security — Grafana docs
- Prometheus alerting rules — Prometheus docs
- Alertmanager configuration — Prometheus docs
- ntfy: message templating — ntfy docs
- Node Exporter Full (dashboard 1860) — Grafana Labs