Prometheus 依赖 Windows Exporter 采集 Windows 主机指标,后者通过 WMI/API 暴露 /metrics 接口;需安装服务、配置启用收集器(如 cpu、memory)、在 prometheus.yml 中添加 target,并可通过 Grafana 导入 ID 12907 面板可视化。
Prometheus 本身不直接采集 Windows 主机指标,必须借助 Windows Exporter(原 wmi_exporter)作为中间桥梁。它运行在 Windows 上,通过 WMI 或系统 API 获取 CPU、内存、磁盘、网络等数据,并以 Prometheus 兼容的文本格式(/metrics)通过 HTTP 暴露出来,再由 Prometheus 定期拉取。
这是第一步,也是最关键的环节:
windows_exporter-*.amd64.msi(适用于 Windows Server 2016+ 或 Win10/11 21H2+)windows_exporter,默认监听 :9182
http://localhost:9182/metrics,能看到大量以 # TYPE 开头的指标文本,说明服务已就绪Windows Exporter 默认启用基础收集器,但建议按需精简,避免冗余指标影响性能和存储:
cpu、logical_disk、net、os、system、memory、service
--collector.logical_disk.ignore-disk-types="CDROM"
.windows_exporter.exe --collectors.enabled="cpu,logical_disk,net,os,system,memory" --web.listen-address=":9182"
config.yaml 文件统一管理,更利于批量部署修改 Prometheus 的配置文件 prometheus.yml,添加 Windows 主机目标:
scrape_configs 下新增一个 job,例如:- job_name: "windows"static_configs:- targets: ["192.168.1.100:9182"]# 替换为实际 Windows 主机 IPmetrics_path: /metrics
http://localhost:9090/targets,确认该 target 状态为 UP
http://localhost:9090/graph 输入 windows_cpu_usage_percent 或 windows_logical_disk_free_bytes 等指标名,可查到实时数据有了指标数据,下一步就是直观呈现:
bingrafana-server.exe),访问 http://localhost:3000
http://localhost:9090)12907 的 Windows Exporter Full,它已预置 CPU、内存、磁盘、服务状态等关键视图