Home Server › Containers

Homelab system metrics with Prometheus and Node Exporter

Deploy Node Exporter and Prometheus in Docker to collect homelab CPU, memory, disk, and network metrics with TSDB retention limits and Nginx Proxy Manager.

Homelab system metrics with Prometheus and Node Exporter

Running a 24/7 homelab without host-level visibility means you only find out about memory leaks or full disks after containers stop responding. This post covers deploying Node Exporter and Prometheus with Docker Compose, setting strict TSDB retention limits, and putting the Prometheus UI behind Nginx Proxy Manager with Basic Auth.

Tested with Prometheus v2.54.1, Node Exporter v1.8.2, and Docker Compose on a Mac mini / Linux homelab host.

Why pull-based monitoring fits a homelab

When you run personal services and side projects around the clock on a Mac mini or a low-power x86 box, failures rarely announce themselves politely. A memory leak in one container pushes the host into heavy swap, or unchecked log files fill the root volume until the Docker daemon freezes completely.

Reacting after an outage is already too late. I wanted a lightweight way to watch CPU, RAM, disk I/O, and network trends continuously so I could spot gradual drift before anything crashed.

For host metrics, I went with the standard Prometheus and Node Exporter stack:

flowchart TD
    subgraph Host["Homelab Host OS"]
        SYS["CPU, Memory, Disk I/O, Network"]
    end

    subgraph Monitoring["Docker Network (monitoring-net)"]
        NE["node-exporter (:9100/metrics)"]
        PROM["prometheus (:9090)"]
        TSDB[("TSDB Storage")]
    end

    subgraph Ingress["External Gateway"]
        NPM["Nginx Proxy Manager (SSL / Basic Auth)"]
        BROWSER["Browser (prometheus.namju.kim)"]
    end

    SYS -->|"Read kernel metrics"| NE
    PROM -->|"Scrape every 15s"| NE
    PROM -->|"Write time-series blocks"| TSDB
    BROWSER -->|"HTTPS + Auth"| NPM
    NPM -->|"Reverse proxy"| PROM

Instead of having agents push metrics to a central collector, Prometheus uses a pull model. The Prometheus server polls each exporter’s /metrics HTTP endpoint on a fixed schedule. That gives me two practical benefits in a homelab:

  • Centralized load control: I adjust scrape intervals in one place (prometheus.yml) instead of reconfiguring every host or service.
  • Built-in liveness detection: If a target stops responding, Prometheus immediately records up == 0 without needing a separate heartbeat check.

When shouldn’t you use this setup? If you only run two or three containers and just want a quick uptime check, a simpler tool like Uptime Kuma takes five minutes to set up and uses almost no disk space. Prometheus pays off once you care about historical trends, PromQL queries, and Grafana dashboards.

How Node Exporter reads host metrics from a container

The most common mistake when running Node Exporter in Docker is starting it without bind-mounting the host filesystems. Because Docker isolates each container in its own namespaces, an unmounted Node Exporter only reports virtual stats for its own container rather than the physical host.

To expose real host metrics, you mount the host kernel filesystems read-only (:ro) into the container and point Node Exporter’s collector flags at those paths:

1
2
3
/proc (host)  --> /host/proc:ro (container)  [--path.procfs=/host/proc]
/sys  (host)  --> /host/sys:ro  (container)  [--path.sysfs=/host/sys]
/     (host)  --> /rootfs:ro    (container)  [--path.rootfs=/rootfs]

Docker also creates dozens of ephemeral overlay filesystems (overlay, shm) and virtual mounts that clutter disk metrics with noise. Passing --collector.filesystem.mount-points-exclude with a regex strips out virtual system paths so Prometheus only tracks real storage volumes.

Always mount host filesystems with the read-only flag (:ro). Granting write access to /, /proc, or /sys turns a compromised exporter container into full host access.

TSDB retention limits for limited homelab storage

Prometheus buffers scraped samples in memory and compacts them into immutable two-hour TSDB blocks on disk. On a homelab with a modest SSD, leaving retention unbounded will eventually fill your disk—causing the exact outage you built monitoring to prevent.

I set three explicit storage flags on the Prometheus container:

  • --storage.tsdb.retention.time=30d: Keeps up to 30 days of metrics and drops older blocks automatically during background compaction.
  • --storage.tsdb.retention.size=20GB: Caps total TSDB disk usage at 20 GB. If storage hits that ceiling before 30 days pass, Prometheus evicts the oldest blocks first.
  • --storage.tsdb.wal-compression: Compresses the Write-Ahead Log (WAL) with Snappy, cutting disk writes and WAL size by roughly 40%.

For the scrape interval (scrape_interval), 15s hits a good balance on homelab hardware. It catches short CPU or I/O spikes without burning noticeable CPU cycles on scraping.

Docker Compose and Prometheus configuration

I keep all monitoring configs under a dedicated directory so the stack stays portable and easy to back up:

1
2
3
4
5
~/homelab-monitoring/
├── .env
├── docker-compose.yml
└── prometheus/
    └── prometheus.yml

Scrape configuration (prometheus/prometheus.yml)

Because both containers share a user-defined Docker bridge network, Prometheus resolves Node Exporter directly by its service name (node-exporter:9100):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# prometheus/prometheus.yml
global:
  scrape_interval: 15s
  evaluation_interval: 15s
  scrape_timeout: 10s

scrape_configs:
  - job_name: "prometheus"
    static_configs:
      - targets: ["localhost:9090"]

  - job_name: "node-exporter"
    static_configs:
      - targets: ["node-exporter:9100"]

Environment file (.env)

Splitting ports and timezone settings into .env keeps docker-compose.yml clean and reusable across hosts:

1
2
3
4
# .env
PROMETHEUS_PORT=9090
NODE_EXPORTER_PORT=9100
TZ=Asia/Seoul

Complete docker-compose.yml

Here is the full Compose file I run. Notice user: "65534:65534" to run Prometheus as nobody, and --web.enable-lifecycle so I can hot-reload config changes via HTTP without restarting the container:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# docker-compose.yml
services:
  prometheus:
    image: prom/prometheus:v2.54.1
    container_name: monitoring-prometheus
    restart: unless-stopped
    user: "65534:65534" # Run as nobody for least privilege
    command:
      - "--config.file=/etc/prometheus/prometheus.yml"
      - "--storage.tsdb.path=/prometheus"
      - "--web.console.libraries=/usr/share/prometheus/console_libraries"
      - "--web.console.templates=/usr/share/prometheus/consoles"
      - "--storage.tsdb.retention.time=30d"
      - "--storage.tsdb.retention.size=20GB"
      - "--storage.tsdb.wal-compression"
      - "--web.enable-lifecycle" # Enable POST /-/reload for hot config reloads
    ports:
      - "${PROMETHEUS_PORT:-9090}:9090"
    volumes:
      - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
      - prometheus_data:/prometheus
    networks:
      - monitoring-net
    depends_on:
      - node-exporter

  node-exporter:
    image: prom/node-exporter:v1.8.2
    container_name: monitoring-node-exporter
    restart: unless-stopped
    command:
      - "--path.procfs=/host/proc"
      - "--path.sysfs=/host/sys"
      - "--path.rootfs=/rootfs"
      - "--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)"
    ports:
      - "${NODE_EXPORTER_PORT:-9100}:9100"
    volumes:
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /:/rootfs:ro
    networks:
      - monitoring-net

volumes:
  prometheus_data:
    name: homelab_prometheus_data

networks:
  monitoring-net:
    name: homelab_monitoring_net
    driver: bridge

In Compose YAML, $$ inside --collector.filesystem.mount-points-exclude escapes the literal $ regex anchor so Docker Compose doesn’t try to interpolate it as an environment variable.

Start the stack in the background:

1
docker compose up -d
1
2
3
4
[+] Running 3/3
 ✔ Network homelab_monitoring_net         Created   0.1s
 ✔ Container monitoring-node-exporter     Started   0.3s
 ✔ Container monitoring-prometheus        Started   0.5s

Securing the Prometheus UI with Nginx Proxy Manager

To check Prometheus remotely over HTTPS, I route prometheus.namju.kim through Nginx Proxy Manager (NPM) using a wildcard Let’s Encrypt certificate (covered in my Cloudflare DDNS and NPM wildcard SSL setup).

Prometheus ships with no built-in login screen or authentication. Exposing port 9090 directly to the internet leaks detailed host telemetry—including internal IP ranges, mount points, and running processes—to anyone who scans your domain.

Proxy Host setup

  1. Open the NPM admin console and go to Hosts > Proxy Hosts > Add Proxy Host.
  2. Fill in the Details tab:
    • Domain Names: prometheus.namju.kim
    • Scheme: http
    • Forward Hostname / IP: your host’s LAN IP or Docker gateway IP (or monitoring-prometheus if NPM shares the same Docker network)
    • Forward Port: 9090
    • Block Common Exploits: ON
    • Websockets Support: ON
  3. Open the SSL tab, pick your wildcard certificate (*.namju.kim), and enable Force SSL, HTTP/2 Support, and HSTS Enabled.

Adding HTTP Basic Auth via Access Lists

Before leaving the proxy host public, lock it down with an NPM Access List:

  1. Go to Access Lists > Add Access List and name it Admin Access Only.
  2. In the Authorization tab, add an admin username and a strong generated password.
  3. Edit the prometheus.namju.kim proxy host, assign Admin Access Only under Access List, and save.

If you already run an SSO gateway like Authelia with NPM, you can protect Prometheus with forward auth instead of Basic Auth.

Verifying scrapes and running core PromQL queries

Once the containers are up, verify both the raw exporter output and the Prometheus scrape status.

Check Node Exporter output

Run curl against port 9100 to confirm Node Exporter is emitting Prometheus text metrics:

1
curl -s http://localhost:9100/metrics | head -n 15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 0
go_gc_duration_seconds{quantile="0.25"} 0
go_gc_duration_seconds{quantile="0.5"} 0
go_gc_duration_seconds{quantile="0.75"} 0
go_gc_duration_seconds{quantile="1"} 0
go_gc_duration_seconds_sum 0
go_gc_duration_seconds_count 0
# HELP node_cpu_seconds_total Seconds the cpus spent in each mode.
# TYPE node_cpu_seconds_total counter
node_cpu_seconds_total{cpu="0",mode="idle"} 18392.12
node_cpu_seconds_total{cpu="0",mode="system"} 412.38
node_cpu_seconds_total{cpu="0",mode="user"} 823.15

Confirm targets are UP

Open the Prometheus UI and navigate to Status > Targets. Both targets should show a green UP state:

1
2
3
Endpoint                           State   Labels                                        Last Scrape
http://localhost:9090/metrics      UP      instance="localhost:9090", job="prometheus"   1.2s ago
http://node-exporter:9100/metrics  UP      instance="node-exporter:9100", job="node-exporter" 2.4s ago

Three PromQL queries for quick host diagnostics

You can paste these directly into the Prometheus Graph tab to check host health:

  1. Total CPU usage (%):
    100 - (avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100)
    

    Averages idle CPU time across all cores over a 5-minute window and subtracts it from 100%.

  2. Actual memory utilization (%):
    (1 - (node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes)) * 100
    

    Uses MemAvailable rather than MemFree so Linux page cache and buffers aren’t miscounted as memory pressure.

  3. Root filesystem usage (%):
    100 - ((node_filesystem_avail_bytes{mountpoint="/rootfs"} * 100) / node_filesystem_size_bytes{mountpoint="/rootfs"})
    

    Calculates disk consumption on the mounted host root (/rootfs).

Caveats and checklist

Before moving on to database metrics or Grafana dashboards, double-check these operational details:

  • Read-only host mounts: Verify /proc, /sys, and / are all mounted :ro and mapped to --path.procfs, --path.sysfs, and --path.rootfs.
  • Dual retention caps: Set both --storage.tsdb.retention.time and --storage.tsdb.retention.size so a sudden cardinality spike can’t fill your SSD.
  • No unauthenticated exposure: Never publish port 9090 on a public IP without Basic Auth or SSO in front of it, and if you only access Prometheus locally or through Grafana, bind 127.0.0.1:9090:9090 instead.
  • Next layer of visibility: Host metrics catch hardware exhaustion, not database bottlenecks. Once this baseline is running, you can add MariaDB and Redis exporters to the same Prometheus instance and visualize everything in Grafana.
This post is licensed under CC BY 4.0 by the author.