Node Exporter on Prometheus
Configuration guide — Integrating Node Exporter for System Metrics
2 min readMay 10, 2024
Introduction
In this article we’ll look at how to add machines that expose system metrics with Node Exporter to the Prometheus log aggregation tool
Prerequisites
- Machines that expose their system metrics using Node Exporter
- Prometheus installed
You’re missing one of the prerequisites? Check my special monitoring list and you’ll find a tutorial on how to do it.
Configuration
Modify the Prometheus configuration file
vim /opt/prometheus/prometheus.yml
Replace the default content with the following
global:
scrape_interval: 15s
evaluation_interval: 15s
alerting:
alertmanagers:
- static_configs:
- targets:
rule_files:
scrape_configs:
- job_name: 'node_exporter'
file_sd_configs:
- files:
- targets.json # Target inventory file
- job_name: "prometheus-metrics"
static_configs:
- targets: ["localhost:9090"]
Add the machines to monitor in the targets file specified in the Prometheus configuration
vim /opt/prometheus/targets.json
[
{
"targets": [ "node1:9100", "node2:9100" ],
"labels": {
"env": "prod",
"custom-label": "example"
}
},
{
"targets": [ "node3:9100" ],
"labels": {
"env": "test",
"custom-label": "example-2"
}
}
]
Restart the service
systemctl restart prometheus.service
Check the service status
systemctl status prometheus.service
Result
Go to http://<ip-of-the-machine>:9090/targets
and make sure that the target have appeared