You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure Windows服务器重启后windows_exporter与Prometheus断连求助

问题根因说明

  • 你提供的Prometheus scrape配置无语法错误,且Linux监控目标运行正常,可直接排除服务端侧配置问题。
  • 该问题属于Windows Server场景下windows_exporter的高频共性问题,暂无批量反馈指向近期Windows更新是诱因。
  • 核心触发逻辑和你观测到的现象完全匹配:windows_exporter启动时Windows网络栈、防火墙规则未完全加载,导致服务仅绑定环回地址127.0.0.1,因此本地访问http://localhost:9182/metrics正常,外部访问被拒绝,重启服务后网络已加载完成,绑定恢复正常。
  • 少数场景下Azure Windows VM动态IP变更、临时防火墙规则失效也会触发同类问题。

可行解决方案

永久修复方案1:强制windows_exporter监听所有网卡

修改服务启动参数,指定监听地址为0.0.0.0,避免仅绑定环回口:

  1. 停止windows_exporter服务
  2. 以管理员权限打开CMD,执行命令(路径替换为实际安装路径,binPath=后的空格不可省略):
sc config windows_exporter binPath= "\"C:\Program Files\windows_exporter\windows_exporter.exe\" --telemetry.address=0.0.0.0:9182 --log.format logger:eventlog?name=windows_exporter"

如果是通过MSI包安装,可在安装时直接指定参数LISTEN_ADDR=0.0.0.0,无需后续手动修改。
3. 重启服务验证外部访问是否正常。

永久修复方案2:调整服务启动依赖

设置windows_exporter依赖网络核心服务,确保网络加载完成后再启动:

  1. 以管理员权限打开CMD,执行命令:
sc config windows_exporter depend= "Dhcp/Dnscache/Netman/ProfSvc"
  1. 将服务启动类型从「自动(延迟启动)」修改为「自动」即可。

永久修复方案3:添加永久防火墙入站规则

手动添加固定的9182端口放行规则,避免临时规则重启失效:
以管理员权限打开PowerShell,执行命令:

New-NetFirewallRule -DisplayName "Allow Prometheus windows_exporter" -Direction Inbound -Protocol TCP -LocalPort 9182 -Action Allow -Enabled True

临时应急方案

可配置Windows定时任务,设置系统启动5分钟后自动重启windows_exporter服务,无需调整现有配置即可解决问题。

内容的提问来源于stack exchange,提问作者Pratik M

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.01 10:45:03