$ run as a normal user# run as root (or with sudo)
The quick answer
On the new server (node_exporter installed and running on port 9100):
curl -s http://127.0.0.1:9100/metrics | grep -m3 '^node_load'
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="10.0.9.10/32" port port="9100" protocol="tcp" accept' && firewall-cmd --reloadOn the Prometheus server: add "web3:9100" to the node job, then:
10.0.9.10 = the Prometheus server — only it may read port 9100.
Step by step
- Install node_exporter on the server (as a systemd service — see the full guide) and check it answers locally (quick answer).
- Open port 9100 only for Prometheus — the metrics show a lot about the server. UFW:
ufw allow from 10.0.9.10 to any port 9100 proto tcp- Add the target to Prometheus, with labels you will filter on later:
- job_name: node
static_configs:
- targets: ["web1:9100", "web2:9100", "db1:9100", "web3:9100"]
labels:
env: prodMany servers: use file_sd_configs (a target list file that Ansible writes) or cloud service discovery (ec2_sd_configs, azure_sd_configs).
- Check and reload, then look at Status → Targets (web3 must be UP):
promtool check config /etc/prometheus/prometheus.yml
systemctl reload prometheus
curl -s 'http://127.0.0.1:9090/api/v1/query?query=up{job="node"}' | jq -r '.data.result[] | .metric.instance + " " + .value[1]'
web1:9100 1
web3:9100 1- The queries you need every day (paste them into the Prometheus or Grafana query box):
| Question | PromQL |
|---|---|
| CPU used % | 100 - avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100 |
| Memory used % | 100 * (1 - node_memory_MemAvailable_bytes / node_memory_MemTotal_bytes) |
| Disk free % | 100 * node_filesystem_avail_bytes{fstype!~"tmpfs|overlay"} / node_filesystem_size_bytes |
| Load per core | node_load5 / count by (instance) (node_cpu_seconds_total{mode="idle"}) |
| Network in (bits/s) | rate(node_network_receive_bytes_total{device!="lo"}[5m]) * 8 |
| Disk full in 4 hours? | predict_linear(node_filesystem_avail_bytes[6h], 4*3600) < 0 |
- Add alerts for down, disk and CPU (the rules file in the full guide), and a dashboard in Grafana.
Check that it worked
The target is UP, the queries return a value for the new server, and in an hour you can see a graph with real history.
Common problems
| Problem | Cause | Fix |
|---|---|---|
Target DOWN: context deadline exceeded | Firewall or security group blocks 9100. | Open 9100 for the Prometheus IP only; test with curl from the Prometheus server. |
Target DOWN: connection refused | node_exporter is not running, or listens on another address. | systemctl status node_exporter; check --web.listen-address. |
no such host | Prometheus can not resolve the name. | Use the IP, or fix DNS / /etc/hosts on the Prometheus server. |
| Disk query shows strange mounts | tmpfs, overlay, snap loops. | Filter fstype and mountpoint labels. |
| Reload did nothing | Config error — Prometheus keeps the old config. | promtool check config; read journalctl -u prometheus. |
| Many servers, the list is hard to keep | Static targets by hand. | file_sd_configs written by Ansible, or cloud service discovery. |
Go further
- Command pages: promtool, node_exporter, curl, jq.
- Next how-tos: Build a Grafana dashboard, Send alerts to Slack or email, Check memory and CPU usage, Define an SLO and an error budget.
- Full guides: Prometheus, Node Exporter. At work: Prometheus, node_exporter.
- Practise: Lab: monitoring stack in one hour.
1Why should port 9100 be open only for the Prometheus server?
The metrics show a lot about the server (versions, disks, network); only the collector needs them.
2Which PromQL function warns before a disk is full?
predict_linear(...) on node_filesystem_avail_bytes.