--- title: "node_exporter" type: entity aliases: [Node Exporter, Prometheus node_exporter] tags: [monitoring, exporter, host-metrics, prometheus, linux] date: 2025-11-11 --- # node_exporter ## Overview node_exporter 是 Prometheus 官方的主机指标采集器,专门采集 Linux/Unix 系统的硬件和操作系统指标。它以守护进程形式运行,暴露一个 `/metrics` HTTP 端点供 Prometheus 抓取。默认端口 9100。设计上遵循无代理(agentless)原则:不需要在被监控主机安装任何特殊软件,只需运行一个独立的进程即可。 ## Key Metrics Collected | 分类 | 指标前缀 | 说明 | |------|----------|------| | CPU | `node_cpu_seconds_total` | 各模式(user/system/idle/iowait)CPU 时间 | | 内存 | `node_memory_MemAvailable_bytes` | 可用内存 | | 磁盘 | `node_filesystem_avail_bytes` | 文件系统可用空间 | | 网络 | `node_network_receive_bytes_total` | 网络接口接收字节 | | 磁盘 I/O | `node_disk_io_time_seconds_total` | 磁盘 I/O 时间 | | 负载 | `node_load1` / `node_load5` / `node_load15` | 系统负载均值 | | inode | `node_filesystem_files_free` | inode 可用数量 | | 时间 | `node_time_seconds` | 系统时间(用于漂移检测) | ## Home Server Deployment(Host Network 模式) ```yaml # docker-compose.yml 片段 node_exporter: image: prom/node-exporter:latest container_name: node_exporter restart: always network_mode: "host" # 关键:使用宿主机网络 pid: "host" # 关键:共享宿主机 PID 命名空间 volumes: - /proc:/host/proc:ro # 只读挂载 - /sys:/host/sys:ro - /:/rootfs:ro ``` > ⚠️ **安全注意**:host network + pid mode 授予容器较高的系统可见性。仅在内网可信环境中使用。 ## Prometheus scrape_config ```yaml - job_name: 'node_exporter' file_sd_configs: - files: - /etc/prometheus/targets/node.yml ``` ## targets/node.yml 示例 ```yaml - targets: - "192.168.3.47:9100" labels: env: home role: server ``` ## Related Sources - [[家庭监控方案-prometheus-grafana-node-exporter-cadvisor-blackbox]] ## Related Entities - [[Prometheus]] — 数据消费者(抓取 node_exporter 的指标) - [[Docker]] — 部署平台 ## Related Concepts - [[Exporter]] — Prometheus 生态中的通用指标暴露组件 - [[Prometheus]] — 上游采集目标 - [[System Monitoring]] — 核心应用领域