Prometheus Node Exporter

Prometheus exporter for hardware and OS metrics exposed by *NIX kernels, written in Go with pluggable metric collectors.

A Dashboard to use with Node Exporter and Grafana can be found here.

Usage

The node_exporter listens on HTTP port 9100 by default.

Docker

The node_exporter is designed to monitor the host system. Deploying in containers requires extra care in order to avoid monitoring the container itself.

For situations where containerized deployment is needed, some extra flags must be used to allow the node_exporter access to the host namespaces.

Be aware that any non-root mount points you want to monitor will need to be bind-mounted into the container.

If you start container for host monitoring, specify path.rootfs argument. This argument must match path in bind-mount of host root. The node_exporter will use path.rootfs as prefix to access host filesystem.

---
version: '3.8'
 
services:
  node_exporter:
    image: quay.io/prometheus/node-exporter:latest
    container_name: node_exporter
    command:
      - '--path.rootfs=/host'
    network_mode: host
    pid: host
    restart: unless-stopped
    volumes:
      - '/:/host:ro,rslave'

On some systems, the timex collector requires an additional Docker flag, --cap-add=SYS_TIME, in order to access the required syscalls.

Prometheus

Configure Prometheus to scrape the exposed node exporter:

global:
  scrape_interval: 15s
 
scrape_configs:
- job_name: node
  static_configs:
  - targets: ['localhost:9100']

Configuration

Node Exporter can be configured using CLI arguments.

Options

OptionDescription
--path.procfs="/proc"procfs mountpoint.
--path.sysfs="/sys"sysfs mountpoint.
--path.rootfs="/"rootfs mountpoint.
--path.udev.data="/run/udev/data"udev data path.
--collector.runit.servicedir="/etc/service"Path to runit service directory.
--collector.supervisord.url="http://localhost:9001/RPC2"XML RPC endpoint.
--collector.sysctl.include=COLLECTOR.SYSCTL.INCLUDE ...Select sysctl metrics to include.
--collector.sysctl.include-info=COLLECTOR.SYSCTL.INCLUDE-INFO ...Select sysctl metrics to include as info metrics.
--collector.systemd.unit-include=".+"Regexp of systemd units to include. Units must both match include and not match exclude to be included.
--collector.systemd.unit-exclude=".+\\.(automount|device|mount|scope|slice|target)"Regexp of systemd units to exclude. Units must both match include and not match exclude to be included.
--collector.systemd.enable-task-metricsEnables service unit tasks metrics unit_tasks_current and unit_tasks_max.
--collector.systemd.enable-restarts-metricsEnables service unit metric service_restart_total.
--collector.systemd.enable-start-time-metricsEnables service unit metric unit_start_time_seconds.
--collector.tapestats.ignored-devices="^$"Regexp of devices to ignore for tapestats.
--collector.textfile.directory="/var/lib/prometheus/node-exporter"Directory to read text files with metrics from.
--collector.vmstat.fields="^(oom_kill|pgpg|pswp|pg.*fault).*"Regexp of fields to return for vmstat collector.
--collector.arpEnable the arp collector (default: enabled).
--collector.bcacheEnable the bcache collector (default: enabled).
--collector.bondingEnable the bonding collector (default: enabled).
--collector.btrfsEnable the btrfs collector (default: enabled).
--collector.buddyinfoEnable the buddyinfo collector (default: disabled).
--collector.cgroupsEnable the cgroups collector (default: disabled).
--collector.conntrackEnable the conntrack collector (default: enabled).
--collector.cpuEnable the cpu collector (default: enabled).
--collector.cpufreqEnable the cpufreq collector (default: enabled).
--collector.diskstatsEnable the diskstats collector (default: enabled).
--collector.dmiEnable the dmi collector (default: enabled).
--collector.drbdEnable the drbd collector (default: disabled).
--collector.drmEnable the drm collector (default: disabled).
--collector.edacEnable the edac collector (default: enabled).
--collector.entropyEnable the entropy collector (default: enabled).
--collector.ethtoolEnable the ethtool collector (default: disabled).
--collector.fibrechannelEnable the fibrechannel collector (default: enabled).
--collector.filefdEnable the filefd collector (default: enabled).
--collector.filesystemEnable the filesystem collector (default: enabled).
--collector.hwmonEnable the hwmon collector (default: enabled).
--collector.infinibandEnable the infiniband collector (default: enabled).
--collector.interruptsEnable the interrupts collector (default: disabled).
--collector.ipvsEnable the ipvs collector (default: enabled).
--collector.ksmdEnable the ksmd collector (default: disabled).
--collector.lnstatEnable the lnstat collector (default: disabled).
--collector.loadavgEnable the loadavg collector (default: enabled).
--collector.logindEnable the logind collector (default: disabled).
--collector.mdadmEnable the mdadm collector (default: enabled).
--collector.meminfoEnable the meminfo collector (default: enabled).
--collector.meminfo_numaEnable the meminfo_numa collector (default: disabled).
--collector.mountstatsEnable the mountstats collector (default: disabled).
--collector.netclassEnable the netclass collector (default: enabled).
--collector.netdevEnable the netdev collector (default: enabled).
--collector.netstatEnable the netstat collector (default: enabled).
--collector.network_routeEnable the network_route collector (default: disabled).
--collector.nfsEnable the nfs collector (default: enabled).
--collector.nfsdEnable the nfsd collector (default: enabled).
--collector.ntpEnable the ntp collector (default: disabled).
--collector.nvmeEnable the nvme collector (default: enabled).
--collector.osEnable the os collector (default: enabled).
--collector.perfEnable the perf collector (default: disabled).
--collector.powersupplyclassEnable the powersupplyclass collector (default: enabled).
--collector.pressureEnable the pressure collector (default: enabled).
--collector.processesEnable the processes collector (default: disabled).
--collector.qdiscEnable the qdisc collector (default: disabled).
--collector.raplEnable the rapl collector (default: enabled).
--collector.runitEnable the runit collector (default: disabled).
--collector.schedstatEnable the schedstat collector (default: enabled).
--collector.selinuxEnable the selinux collector (default: enabled).
--collector.slabinfoEnable the slabinfo collector (default: disabled).
--collector.sockstatEnable the sockstat collector (default: enabled).
--collector.softnetEnable the softnet collector (default: enabled).
--collector.statEnable the stat collector (default: enabled).
--collector.supervisordEnable the supervisord collector (default: disabled).
--collector.sysctlEnable the sysctl collector (default: disabled).
--collector.systemdEnable the systemd collector (default: enabled).
--collector.tapestatsEnable the tapestats collector (default: enabled).
--collector.tcpstatEnable the tcpstat collector (default: disabled).
--collector.textfileEnable the textfile collector (default: enabled).
--collector.thermal_zoneEnable the thermal_zone collector (default: enabled).
--collector.timeEnable the time collector (default: enabled).
--collector.timexEnable the timex collector (default: enabled).
--collector.udp_queuesEnable the udp_queues collector (default: enabled).
--collector.unameEnable the uname collector (default: enabled).
--collector.vmstatEnable the vmstat collector (default: enabled).
--collector.wifiEnable the wifi collector (default: disabled).
--collector.xfsEnable the xfs collector (default: enabled).
--collector.zfsEnable the zfs collector (default: enabled).
--collector.zoneinfoEnable the zoneinfo collector (default: disabled).
--web.telemetry-path="/metrics"Path under which to expose metrics.
--web.disable-exporter-metricsExclude metrics about the exporter itself (promhttp_*, process_*, go_*).
--web.max-requests=40Maximum number of parallel scrape requests. Use 0 to disable.
--collector.disable-defaultsSet all collectors to disabled by default.
--runtime.gomaxprocs=1The target number of CPUs Go will run on (GOMAXPROCS).
--web.systemd-socketUse systemd socket activation listeners instead of port listeners (Linux only).
--web.listen-address=:9100 ...Addresses on which to expose metrics and web interface. Repeatable for multiple addresses.
--web.config.file=""[EXPERIMENTAL] Path to configuration file that can enable TLS or authentication.
--log.level=infoOnly log messages with the given severity or above. One of: [debug, info, warn, error].
--log.format=logfmtOutput format of log messages. One of: [logfmt, json].

Web Configuration

Exporters and services instrumented with the Exporter Toolkit share the same web configuration file format. This is experimental and might change in the future.

To specify which web configuration file to load, use the --web.config.file flag.

Basic config file:

# TLS and basic authentication configuration example.
#
# Additionally, a certificate and a key file are needed.
tls_server_config:
  cert_file: server.crt
  key_file: server.key
 
# Usernames and passwords required to connect.
# Passwords are hashed with bcrypt: https://github.com/prometheus/exporter-toolkit/blob/master/docs/web-configuration.md#about-bcrypt.
basic_auth_users:
  alice: $2y$10$mDwo.lAisC94iLAyP81MCesa29IzH37oigHC/42V2pdJlUprsJPze
  bob: $2y$10$hLqFl9jSjoAAy95Z/zw8Ye8wkdMBM8c5Bn1ptYqP/AXyV0.oy0S8m