Installing and configuring Prometheus Node Exporter on Amazon Linux, CentOS & RHEL
- Create a system user:
sudo useradd --no-create-home --shell /bin/false node_exporter
- Download the Node Exporter from Prometheus’s download page:
cd /tmp/ wget https://github.com/prometheus/node_exporter/releases/download/v0.17.0/node_exporter-0.17.0.linux-amd64.tar.gz
- Extract its contents; note that the versioning of the Node Exporter may be different:
tar -xvf node_exporter-0.17.0.linux-amd64.tar.gz
- Move into the newly created directory:
cd node_exporter-0.17.0.linux-amd64/
- Move the provided binary:
sudo mv node_exporter /usr/local/bin/
- Set the ownership:
sudo chown node_exporter:node_exporter /usr/local/bin/node_exporter
- Create a systemd service file:
sudo vim /etc/systemd/system/node_exporter.service [Unit] Description=Node Exporter After=network.target [Service] User=node_exporter Group=node_exporter Type=simple ExecStart=/usr/local/bin/node_exporter [Install] WantedBy=multi-user.target
Save and exit when done.
- Start the Node Exporter:
sudo systemctl daemon-reload sudo systemctl start node_exporter
- Add the endpoint to the Prometheus configuration file:
sudo EDITOR /etc/prometheus/prometheus.yml - job_name: 'nodeexporter' static_configs: - targets: ['localhost:9100']
- Restart Prometheus:
sudo systemctl restart prometheus
- Navigate to the Prometheus web UI. Using the expression editor, search for cpu, meminfo, and related system terms to view the newly added metrics.
- Search for node_memory_MemFree_bytes in the expression editor; shorten the time span for the graph to be about 30 minutes of data.
- Back on the terminal, download and run stress to cause some memory spikes:
sudo apt-get install stress stress -m 2
- Wait for about one minute, and then view the graph to see the difference in activity.