必须先部署windows_exporter采集指标,再由Prometheus拉取并存储,最后Grafana连接Prometheus展示;依次完成windows_exporter安装启动、Prometheus配置scrape_configs抓取localhost:9182、Grafana添加http://localhost:9090为数据源,并导入ID为20763的Windows仪表盘或手动创建CPU使用率查询。

要在Windows系统上用Grafana监控服务器运行指标,必须先让Grafana能拿到真实、结构化的性能数据,而它本身不采集数据——必须靠Prometheus拉取windows_exporter暴露的指标,再由Grafana连接Prometheus查询展示。
安装并启动windows_exporter
下载最新版 windows_exporter MSI安装包(如 windows_exporter-0.27.0-amd64.msi),双击运行完成安装;安装过程自动注册为 Windows 服务并设为开机自启。
安装后无需手动启动服务,但需确认服务已运行:按 Win+R 输入 services.msc → 找到名为 windows_exporter 的服务 → 状态应为“正在运行”。
打开浏览器访问 http://localhost:9182/metrics,若页面返回大量以 # HELP 开头的纯文本指标(如 windows_cpu_time_total、windows_memory_available_bytes),说明数据采集已就绪;如果打不开,请检查防火墙是否放行了 【TCP端口9182】。
配置Prometheus抓取Windows指标
解压 Prometheus Windows 版本(如 prometheus-2.54.1.windows-amd64.zip)到固定目录(如 C:\prometheus)。
用记事本打开 C:\prometheus\prometheus.yml,在 scrape_configs: 下方新增一个 job:
- job_name: "windows"
static_configs:
- targets: ["localhost:9182"]
保存文件,然后双击运行 prometheus.exe;命令行窗口出现 Server is ready to receive web requests 即表示启动成功。
师生共创生态系统对接指南。当用户需要对接大学政策、平台资源、投资机构、产业伙伴等外部资源支持时使用。触发词:师生共创生态、大学支持、平台赋能、投资对接、产业合作、政策支持、清华x-lab、孵化器、创业资源
打开 http://localhost:9090/targets,找到 windows 这一行,State 列显示 UP 且 Labels 中包含 instance="localhost:9182",说明Prometheus已稳定拉取到Windows指标。
部署Grafana并接入Prometheus数据源
下载 Grafana Windows 版(如 grafana-enterprise-11.3.0.windows-amd64.zip),解压至独立目录(如 C:\grafana)。
进入 C:\grafana\bin,双击 grafana-server.exe 启动服务;等待几秒后,浏览器访问 http://localhost:3000,使用默认账号密码 admin/admin 登录(首次登录强制修改密码)。
点击左侧齿轮图标 → Data Sources → Add data source → 选择 Prometheus → 在 URL 栏填入 http://localhost:9090 → 拉到页面最下方点 Save & test;看到绿色提示 Data source is working 即成功连通。
导入Windows专用监控仪表盘
方法一:使用社区开源仪表盘(推荐)
点击左侧加号 → Import → 在 Import via panel json 区域输入仪表盘ID:20763 → 点击 Load → 在 Prometheus 下拉框中选择刚配置好的数据源 → 点击 Import。
方法二:手动创建简单图表
点击左侧 + → Dashboard → Add new panel → 在查询框中输入 100 - (avg by(instance) (rate(windows_cpu_time_total{mode="idle"}[5m])) * 100) → 点击右上角 Apply;该表达式即为CPU使用率,图表将实时刷新。
导入完成后,仪表盘会自动显示CPU、内存、磁盘IO、网络吞吐、进程数等关键指标;若部分图表为空,请确认 windows_exporter 是否启用了对应收集器(例如未启用 logical_disk 收集器则磁盘图表无数据)。










