In this blog post, i will guide you through setting up Node Exporter on a new server and integrating it with an existing Prometheus server. Node Exporter is a Prometheus exporter that exposes system-level metrics about your servers, which can be collected and visualized using Prometheus and Grafana.
Step 1: Install Node Exporter on the new server
1.1. Identify your system’s architecture:
uname -m
1.2. Download the appropriate Node Exporter binary for your system’s architecture. For aarch64
(ARM64) systems:
wget https://github.com/prometheus/node_exporter/releases/download/vX.Y.Z/node_exporter-X.Y.Z.linux-arm64.tar.gz
Replace X.Y.Z
with the latest version number.
1.3. Extract the downloaded archive:
tar -xvf node_exporter-X.Y.Z.linux-arm64.tar.gz
1.4. Move the node_exporter
binary to /usr/local/bin
:
sudo mv node_exporter-X.Y.Z.linux-arm64/node_exporter /usr/local/bin/
Step 2: Create a Systemd service for Node Exporter
2.1. Create a new service file:
sudo nano /etc/systemd/system/node_exporter.service
2.2. Add the following content to the file:
[Unit]
Description=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
[Install]
WantedBy=multi-user.target
2.3. Save and close the file.
2.4. Create a user and group for Node Exporter:
sudo useradd -M -r -s /bin/false node_exporter
2.5. Reload the Systemd configuration:
sudo systemctl daemon-reload
2.6. Enable and start the Node Exporter service:
sudo systemctl enable node_exporter
sudo systemctl start node_exporter
Step 3: Verify that Node Exporter is running
curl http://localhost:9100/metrics
You should see a list of metrics exposed by Node Exporter.
Step 4: Add the new server to the existing Prometheus server
4.1. Edit the Prometheus configuration file (usually located at /etc/prometheus/prometheus.yml
):
sudo nano /etc/prometheus/prometheus.yml
4.2. Add the new server to the scrape_configs
section:
codescrape_configs:
- job_name: 'node_exporter'
static_configs:
- targets: ['localhost:9100', 'new_server_ip_or_hostname:9100']
Replace new_server_ip_or_hostname
with the IP address or hostname of your new server.
4.3. Save and close the file.
4.4. Restart the Prometheus service:
sudo systemctl restart prometheus
Step 5: Check the Prometheus dashboard
Access the Prometheus dashboard in your web browser at http://<your_prometheus_server_ip_or_hostname>:9090
. You should now see the new server’s metrics in the “Targets” and “Graph” sections.
Conclusion:
You have successfully set up Node Exporter on a new server and integrated it with your existing Prometheus server. Now, you can collect and visualize your server’s system-level metrics using Prometheus and Grafana.