Node Exporter
NotesThe 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.gztar -xvf node_exporter-1.13.1.linux-amd64.tar.gzAnd 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 --versionAdd a system user for running node_exporter, with no home directory or login:
sudo useradd --system --no-create-home --shell /sbin/nologin node_exporterAnd a systemd service:
[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.targetStart it, enable it at boot, and check its status:
sudo systemctl daemon-reloadsudo systemctl enable node_exporter --nowsudo systemctl status node_exporterOn 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:
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['prometheus:9090']
- job_name: 'node_exporter' # NEW
static_configs: # NEW
- targets: ['host.containers.internal:9100'] # NEWIf firewalld is running, the container’s connection to the host may be blocked, so open the port:
sudo firewall-cmd --add-port=9100/tcp --permanentsudo firewall-cmd --reloadAnd restart Prometheus:
podman restart prometheusAll being well, you should now have two targets being scraped by Prometheus, prometheus (itself) and node_exporter.