Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
Wat het doet
node_exporter runs on every server and shows hardware and OS metrics at http://HOST:9100/metrics. Prometheus scrapes it. Collectors can be turned on or off (--collector.systemd, --no-collector.wifi). The textfile collector reads *.prom files, so your own scripts (backup age, certificate expiry) can add metrics.
In Kubernetes, kube-prometheus-stack installs it as a DaemonSet. Windows uses windows_exporter.
Zo schrijf je het
node_exporter [--collector.NAME] [--no-collector.NAME] [--web.listen-address=:9100]Belangrijkste delen
Important metrics
node_cpu_seconds_total- CPU time per mode (idle, user, system, iowait).
node_memory_MemAvailable_bytes- Memory that apps can still use.
node_filesystem_avail_bytes- Free space per mount.
node_disk_io_time_seconds_total- Disk busy time.
node_network_receive_bytes_total- Network traffic.
node_load1/node_load5- Load average.
node_systemd_unit_state- State of systemd units (with --collector.systemd).
node_textfile_*- Your own metrics from the textfile collector.
Opties 6
Meest gebruikt
Flags
Niets past bij dit filter.
Voorbeelden 10
$ als gewone gebruiker# als root (of met sudo)
1Install from EPEL or the release tarball
2Run it as a hardened systemd service
cat /etc/systemd/system/node_exporter.service [Service] User=node_exporter ExecStart=/usr/local/bin/node_exporter --collector.systemd --collector.textfile.directory=/var/lib/node_exporter NoNewPrivileges=yes ProtectSystem=strict ProtectHome=yes ReadOnlyPaths=/3Allow only the Prometheus server
firewall-cmd --permanent --add-rich-rule='rule family=ipv4 source address=10.20.0.5/32 port port=9100 protocol=tcp accept' firewall-cmd --reload4Check key numbers by hand
5Add your own metric with the textfile collector
cat /usr/local/bin/backup-metric.sh #!/bin/bash echo "backup_last_success_timestamp_seconds $(date +%s)" > /var/lib/node_exporter/backup.prom.$$ mv /var/lib/node_exporter/backup.prom.$$ /var/lib/node_exporter/backup.prom6Alert when the backup is older than 26 hours
cat rules/backup.yml groups: - name: backup rules: - alert: BackupTooOld expr: time() - backup_last_success_timestamp_seconds > 26*36007Scrape it from Prometheus
cat prometheus.yml scrape_configs: - job_name: node static_configs: [{ targets: ["web1:9100", "web2:9100"] }]8Protect it with TLS and basic auth
cat /etc/node_exporter/web.yml tls_server_config: { cert_file: /etc/node_exporter/node.crt, key_file: /etc/node_exporter/node.key } basic_auth_users: { prometheus: "$2y$10$examplebcrypthashonly000000000000000000000000000000" }9See failed systemd units as metrics
10Check the exporter itself
Niets past bij dit filter.
Let op
- Metrics show host names, kernel versions and mount points — do not expose port 9100 to the internet.
- Write textfile metrics atomically (temp file + mv), or Prometheus may read half a file.
Bestanden
/var/lib/node_exporter/*.prom- Textfile collector files (path is your choice).
Tips om te onthouden
- Use the "Node Exporter Full" Grafana dashboard (ID 1860) as a start.
Exitcodes
0 | Clean stop. |
1 | Error at start (bad flag, port in use). |