Node Exporter is a Prometheus exporter for server level and OS level metrics with configurable metric collectors. It helps us in measuring various server resources such as RAM, disk space, and CPU utilization. Node exporter is a good solution to collect all the Linux server-related metrics and statistics for monitoring.
Before Start
- Prometheus Server
After node exporter installation, you should send your metrics to the Prometheus server. - Sudo Privileges
You should access your server via SSH with root or your ssh login user should have root privileges with sudo.
Node Exporter Installation Steps
- Create a directory
I prefer to use
/opt/
node-exporter path for installation. You can also use. - Add user
You can add a user with a simple command. It’s:
adduser -r -d /opt/node-exporter node-exporter -s /sbin/nologin
- Download the binary
Download the binary from https://github.com/prometheus/node_exporter/releases page and extract the files to
/opt/node-exporter
path directly. - Change Owner and Group Permissions
Now, need to set user permissions to execute node_exporter binary.
chown -R
node-exporter:node-exporter/opt/
node-exporter - Create a systemd service file
We should manage this service status with systemd. Now, time to create a systemd service file. The file path should
/etc/systemd/system/node-exporter.service
You can paste all configurations below into it.[Unit]
Description=Prometheus exporter for machine metrics
Documentation=https://github.com/flightlesstux/node_exporter
[Service]
Restart=always
User=node-exporter
Gorup=node-exporter
ExecStart=/opt/node-exporter/node_exporter
ExecReload=/bin/kill -HUP $MAINPID
TimeoutStopSec=20s
SendSIGKILL=no
[Install]
WantedBy=multi-user.target - Start the node-exporter
Now, you can ready to start your node-exporter service with
systemctl start node-exporter
command.
Now, you can see your servers metrics via http://IP_ADDRESS:9100/metrics url. If you can’t reach the page, you should check your firewall and/or security group settings to allow TCP 9100.
Bonus
Now, you now the steps and what you need for install Node Exporter. I turned this installation to automation and you can feel free to use. Just run the command sh <(curl https://raw.githubusercontent.com/flightlesstux/node_exporter/master/installer.sh)
and in a few seconds, your node-exporter will be installed.
GitHub Repository: https://github.com/flightlesstux/node_exporter