Operations 13 min read

How to Install, Configure, and Monitor Node Exporter with Prometheus

This guide walks through installing the Go‑based Node Exporter, configuring it as a systemd service or Docker container, exposing standard Prometheus metrics, and using PromQL to calculate CPU usage across multiple nodes.

Ops Development Stories
Ops Development Stories
Ops Development Stories
How to Install, Configure, and Monitor Node Exporter with Prometheus

Node Exporter is a Go‑written exporter that exposes *NIX host metrics such as CPU, memory, and disk without any third‑party dependencies; you only need to download, extract, and run the binary.

Installation and Configuration

Download the tarball from the Prometheus download page, extract it, and run the

node_exporter

binary:

<code>wget https://github.com/prometheus/node_exporter/releases/download/v1.2.2/node_exporter-1.2.2.linux-amd64.tar.gz
# Optional fast download for China
# wget https://download.fastgit.org/prometheus/node_exporter/releases/download/v1.2.2/node_exporter-1.2.2.linux-amd64.tar.gz
 tar -xvf node_exporter-1.2.2.linux-amd64.tar.gz
 cd node_exporter-1.2.2.linux-amd64
 ./node_exporter</code>

The log shows that Node Exporter listens on port 9100 and serves metrics at the

/metrics

endpoint, which can be accessed with:

<code>curl http://localhost:9100/metrics</code>

The output follows the standard Prometheus exposition format, ready to be scraped by Prometheus.

Run

./node_exporter -h

to see all configurable flags. The most important flag is

--collector.&lt;name&gt;

, which enables specific metric collectors. Use

--no-collector.&lt;name&gt;

to disable defaults, or

--collector.disable-defaults

followed by explicit

--collector.&lt;name&gt;

entries.

For production, you can run Node Exporter in a Docker container (remember to grant access to the host’s namespaces) or manage it with systemd. Below is a typical systemd unit file:

<code>[Unit]
Description=node exporter service
Documentation=https://prometheus.io
After=network.target

[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/local/bin/node_exporter
Restart=on-failure

[Install]
WantedBy=multi-user.target</code>

After placing the binary in

/usr/local/bin

, reload the daemon and start the service:

<code>cp node_exporter /usr/local/bin/node_exporter
systemctl daemon-reload
systemctl start node_exporter
systemctl status node_exporter</code>

Add a static scrape job for the two nodes in Prometheus configuration:

<code>global:
  scrape_interval: 5s

scrape_configs:
  - job_name: "prometheus"
    static_configs:
      - targets: ["localhost:9090"]
  - job_name: "demo"
    scrape_interval: 15s
    scrape_timeout: 10s
    static_configs:
      - targets: ["localhost:10000", "localhost:10001", "localhost:10002"]
  - job_name: "node_exporter"
    static_configs:
      - targets: ["node1:9100", "node2:9100"]</code>

CPU Monitoring

The metric

node_cpu_seconds_total

records the cumulative CPU time spent in each mode (idle, user, system, etc.) as a counter. Sample output shows values for each CPU core and mode.

To derive CPU usage percentage, calculate the proportion of time not spent in the

idle

mode. Using PromQL, first get the increase of idle time over a 1‑minute window, then compute the ratio against the total CPU time:

<code>(1 - sum(increase(node_cpu_seconds_total{mode="idle"}[1m])) by (instance) / sum(increase(node_cpu_seconds_total[1m])) by (instance)) * 100</code>

This expression yields the CPU utilization per instance, comparable to the percentages shown by the

top

command.

Further node‑level metrics such as memory and I/O will be covered in upcoming articles.

monitoringPrometheusCPUpromqlsystemdnode exporter
Ops Development Stories
Written by

Ops Development Stories

Maintained by a like‑minded team, covering both operations and development. Topics span Linux ops, DevOps toolchain, Kubernetes containerization, monitoring, log collection, network security, and Python or Go development. Team members: Qiao Ke, wanger, Dong Ge, Su Xin, Hua Zai, Zheng Ge, Teacher Xia.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.