Skip to content

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/admin default before anything else. Step 0 sets a real password from the start.
  • Pin image versions. latest can change under you on the next pull.
  • The video hard-codes job="jenkins-node" and instance="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

  1. 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
    
  2. Start it: docker compose up -d

  3. Check all three are up: docker compose ps
  4. 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]*"'
    
  5. Check nothing is exposed. Every line must start with 127.0.0.1:

    sudo ss -tlnp | grep -E ':(3000|9090|9100)\b'
    
  6. 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-server
    

    Log in as admin with 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.1 avoids both problems without opening anything.

Common mistakes

  • Leaving out --web.listen-address. The default is every network card, not just this machine.
  • Using latest tags, then finding the stack changed after a routine pull.
  • Running docker compose down -v. The -v deletes 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

  1. 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.
  2. Find one you will use. Search for node_cpu_seconds_total. You will see one line per CPU core per mode (user, system, idle and 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:

  1. In the left menu open Connections, then Data sources, then Add data source.
  2. Pick Prometheus.
  3. In Prometheus server URL enter http://127.0.0.1:9090.
  4. Scroll to the bottom and click Save & test. You want the green "Successfully queried the Prometheus API."

Grafana 13 data source page showing the green success message after Save and test.

Common mistakes

  • Typing localhost:9090 without http://.
  • 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

  1. Start a dashboard. In the left menu click Dashboards, then New, then New dashboard.

    A new empty dashboard in Grafana 13, with the Add pane open on the right and the Panel tile at the top.

  2. Add a panel. In the Add pane on the right, click the Panel tile. A "New panel" box appears; click Configure visualization inside it.

  3. Switch to typing mode. Under the chart, next to Run queries, change Builder to Code.
  4. Type the stage 3 query and click Run queries.
  5. Pick the chart type. The right-hand pane now shows Suggestions. Click the first one, Time series.

    The panel editor after running the CPU query: the chart on the left, the query in Code mode below it, and Time series suggestions on the right.

  6. Clean up the legend. Under the query, open Options. Set Legend to Custom and type {{mode}}. Each line is now named user, system, iowait and so on (7:47).

  7. 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).

    Setting the unit: Standard options, Unit, with the Percent choices shown. The custom legend field is visible at the bottom left.

  8. Name the panel. At the top of the right-hand pane, under Panel options, set Title to CPU utilization.

  9. 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.

    The Save dashboard drawer with the Title field filled in.

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 adding avg without (cpu). The video hits this error too (6:40).

Beyond the video

  • Use rate, not irate. The video uses irate(...[1m]) for sharper detail (4:42). irate looks 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 recommends rate for 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 job and instance. 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

  1. 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.
  2. Switch to Code and enter the first query. Set its legend (Options, Legend, Custom) to Used.
  3. 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
    Used node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes
    Buffers node_memory_Buffers_bytes
    Cached node_memory_Cached_bytes
    Free node_memory_MemFree_bytes
  4. Click Run queries, then choose the Time series suggestion.

  5. Set the unit. Standard options, Unit, type bytes, choose Data / bytes(IEC) (12:03). The axis now reads in GiB.
  6. Title it Memory usage and 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 MemAvailable for 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_bytes with 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

  1. Add a panel as in Step 3 (Edit, Add panel, Configure visualization) and switch to Code.
  2. Enter the query:

    node_filesystem_size_bytes{fstype=~"ext4|xfs|btrfs|vfat"} - node_filesystem_avail_bytes{fstype=~"ext4|xfs|btrfs|vfat"}
    
  3. Legend: Custom, {{mountpoint}}.

  4. Run queries, choose Time series.
  5. Unit: Data / bytes(IEC) (17:00).
  6. Title it Disk space used and 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, nsfs and gvfsd-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. Add zfs or others if you use them.
  • Legend by mount point. / and /boot mean 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.
  • avail is the space ordinary programs can use. node_filesystem_free_bytes also 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

  1. Add a panel, Configure visualization, switch to Code.
  2. Enter the query: node_filesystem_avail_bytes{fstype=~"ext4|xfs|btrfs|vfat"}
  3. Legend: Custom, {{mountpoint}}. Unit: Data / bytes(IEC).
  4. Title it Disk space available and 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

  1. Add a panel, Configure visualization, switch to Code.
  2. Enter two queries (use Add query for the second), each with a custom legend:

    Legend Query
    {{device}} receive rate(node_network_receive_bytes_total{device!~"lo|veth.*|docker.*|br-.*"}[$__rate_interval]) * 8
    {{device}} transmit rate(node_network_transmit_bytes_total{device!~"lo|veth.*|docker.*|br-.*"}[$__rate_interval]) * 8
  3. Run queries, choose Time series.

  4. Unit: Standard options, Unit, type bits, choose Data rate / bits/sec(SI).
  5. Title it Network traffic and Save.

Common mistakes

  • Seeing only lo and eth0 when 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.
  • rate and $__rate_interval replace the video's irate(...[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

  1. 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.
  2. 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.
  3. 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 in Grafana 13: CPU and memory on the top row, disk used and available below, network traffic at the bottom.

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

  1. 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: 10m means 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.

  2. 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"]
    
  3. 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-url
    

    The ?template=alertmanager ending tells ntfy to turn Alertmanager's raw data into a readable message.

  4. 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
    
  5. Add Alertmanager to compose.yml under services:, then run docker 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:ro
    

    The empty --cluster.listen-address= matters. Without it Alertmanager opens a second port on every network card.

  6. Reload Prometheus: docker compose kill -s SIGHUP prometheus

  7. Subscribe on your phone. Install the ntfy app, tap +, and enter the topic name (the part of the address between ntfy.sh/ and ?).
  8. 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

  1. Keep Prometheus, node-exporter and Alertmanager private, always. They have no login. Only Grafana should ever be shared.
  2. Prefer private access. The SSH tunnel from Step 0 or a private network such as Tailscale exposes nothing to the internet.
  3. 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_URL Broken links and redirects behind a proxy
    COOKIE_SECURE The login cookie being sent over plain HTTP
    HIDE_VERSION Strangers reading your exact Grafana version before logging in
    METRICS_ENABLED: false Grafana's own /metrics page, which needs no login by default
  4. Give other people their own accounts with the Viewer role (Administration, Users and access, Users, New user). Never share the admin password.

  5. 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 v with 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.1 only — Step 0
  • Grafana password set in .env; admin/admin does 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