Node Exporter

The node_exporter publishes metrics about the computer it runs on: CPU, memory, disks, network and so on. Its documentation recommends running it directly on the host rather than in a container, since it needs to see the host system.

Find the latest version at https://github.com/prometheus/node_exporter/releases/, for example:

curl -LO https://github.com/prometheus/node_exporter/releases/download/v1.13.1/node_exporter-1.13.1.linux-amd64.tar.gz
tar -xvf node_exporter-1.13.1.linux-amd64.tar.gz

And copy the node_exporter binary into a directory on the PATH:

sudo cp node_exporter-1.13.1.linux-amd64/node_exporter /usr/local/bin/

Check that everything is working:

node_exporter --version

Add a system user for running node_exporter, with no home directory or login:

sudo useradd --system --no-create-home --shell /sbin/nologin node_exporter

And a systemd service:

/etc/systemd/system/node_exporter.serviceini
[Unit]
Description=Prometheus Node Exporter
Wants=network-online.target
After=network-online.target

[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/usr/local/bin/node_exporter --web.listen-address=:9100

[Install]
WantedBy=multi-user.target

Start it, enable it at boot, and check its status:

sudo systemctl daemon-reload
sudo systemctl enable node_exporter --now
sudo systemctl status node_exporter

On Fedora and RHEL, SELinux may stop a binary copied into /usr/local/bin from running as a service. If systemctl status shows a permission error, restore its label with sudo restorecon -v /usr/local/bin/node_exporter.

You can see its metrics at http://localhost:9100/metrics.

Prometheus, in its container, reaches your computer as host.containers.internal. Add a scrape job to prometheus.yml:

~/volumes/prometheus/prometheus.ymlyaml
scrape_configs:
  - job_name: 'prometheus'
    static_configs:
      - targets: ['prometheus:9090']
  - job_name: 'node_exporter'  # NEW
    static_configs:  # NEW
      - targets: ['host.containers.internal:9100']  # NEW

If firewalld is running, the container’s connection to the host may be blocked, so open the port:

sudo firewall-cmd --add-port=9100/tcp --permanent
sudo firewall-cmd --reload

And restart Prometheus:

podman restart prometheus

All being well, you should now have two targets being scraped by Prometheus, prometheus (itself) and node_exporter.