Filters
How to search
  • Plain words find names, texts and examples.
  • "two words" finds the exact phrase.
  • --name or -x finds an option.
  • #word looks only inside commands.
  • @grep finds lessons and labs that use grep.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Put ! before a word to leave it out. OR between words means one of them.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search

node_exporter

The Prometheus exporter for Linux hosts: CPU, memory, disks, file systems, network and systemd metrics on port 9100.

Level
DevSecOps service
Group
Monitoring and logging
Needs root
For changes
Package
node_exporter

What it does

node_exporter runs on every server and shows hardware and OS metrics at http://HOST:9100/metrics. Prometheus scrapes it. Collectors can be turned on or off (--collector.systemd, --no-collector.wifi). The textfile collector reads *.prom files, so your own scripts (backup age, certificate expiry) can add metrics.

In Kubernetes, kube-prometheus-stack installs it as a DaemonSet. Windows uses windows_exporter.

How to write it

node_exporter [--collector.NAME] [--no-collector.NAME] [--web.listen-address=:9100]

Main parts

Important metrics

node_cpu_seconds_total
CPU time per mode (idle, user, system, iowait).
node_memory_MemAvailable_bytes
Memory that apps can still use.
node_filesystem_avail_bytes
Free space per mount.
node_disk_io_time_seconds_total
Disk busy time.
node_network_receive_bytes_total
Network traffic.
node_load1 / node_load5
Load average.
node_systemd_unit_state
State of systemd units (with --collector.systemd).
node_textfile_*
Your own metrics from the textfile collector.

Options 6

Most used

Flags

--web.listen-address=:9100
Address and port.
--web.config.file=FILE
TLS and basic auth.
--collector.systemd
Turn on systemd unit metrics.
--collector.textfile.directory=DIR
Folder with *.prom files.
--no-collector.NAME
Turn a collector off.
--collector.filesystem.mount-points-exclude=REGEX
Skip some mounts.

Examples 10

$ run as a normal user# run as root (or with sudo)

  1. 1Install from EPEL or the release tarball

    dnf install -y golang-github-prometheus-node-exporter
    systemctl enable --now prometheus-node-exporter
    curl -s localhost:9100/metrics | head
  2. 2Run it as a hardened systemd service

    cat /etc/systemd/system/node_exporter.service
    [Service]
    User=node_exporter
    ExecStart=/usr/local/bin/node_exporter --collector.systemd --collector.textfile.directory=/var/lib/node_exporter
    NoNewPrivileges=yes
    ProtectSystem=strict
    ProtectHome=yes
    ReadOnlyPaths=/
  3. 3Allow only the Prometheus server

    firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=10.20.0.5/32 port port=9100 protocol=tcp accept'
    firewall-cmd --reload
  4. 4Check key numbers by hand

    curl -s localhost:9100/metrics | grep -E '^node_memory_MemAvailable_bytes|^node_load1 '
    curl -s localhost:9100/metrics | grep 'node_filesystem_avail_bytes{.*mountpoint="/"'
  5. 5Add your own metric with the textfile collector

    cat /usr/local/bin/backup-metric.sh
    #!/bin/bash
    echo "backup_last_success_timestamp_seconds $(date +%s)" > /var/lib/node_exporter/backup.prom.$$
    mv /var/lib/node_exporter/backup.prom.$$ /var/lib/node_exporter/backup.prom
  6. 6Alert when the backup is older than 26 hours

    cat rules/backup.yml
    groups:
      - name: backup
        rules:
          - alert: BackupTooOld
            expr: time() - backup_last_success_timestamp_seconds > 26*3600
  7. 7Scrape it from Prometheus

    cat prometheus.yml
    scrape_configs:
      - job_name: node
        static_configs: [{ targets: ["web1:9100", "web2:9100"] }]
  8. 8Protect it with TLS and basic auth

    cat /etc/node_exporter/web.yml
    tls_server_config: { cert_file: /etc/node_exporter/node.crt, key_file: /etc/node_exporter/node.key }
    basic_auth_users: { prometheus: "$2y$10$examplebcrypthashonly000000000000000000000000000000" }
  9. 9See failed systemd units as metrics

    curl -s localhost:9100/metrics | grep 'node_systemd_unit_state{.*state="failed"} 1'
  10. 10Check the exporter itself

    curl -s localhost:9100/metrics | grep node_exporter_build_info

Watch out

  • Metrics show host names, kernel versions and mount points — do not expose port 9100 to the internet.
  • Write textfile metrics atomically (temp file + mv), or Prometheus may read half a file.

Files

/var/lib/node_exporter/*.prom
Textfile collector files (path is your choice).

Tips to remember

  • Use the "Node Exporter Full" Grafana dashboard (ID 1860) as a start.

Exit codes

0Clean stop.
1Error at start (bad flag, port in use).

Full manual

This page explains the command in simple words. The original manual has every detail.

In your terminal: man node_exporter