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

Windows Exporter IIS站点白名单失效及指标过滤配置咨询

解决Windows Exporter IIS相关问题

1. 正则表达式'Api.+'筛选失效的修复

Windows Exporter的IIS模块正则匹配的是站点名称,而非应用程序名称。若目标是筛选站点名称以Api开头的站点,需调整配置:

  • 使用Go语言兼容的正则语法(Windows Exporter基于Go开发),建议用锚定开头的表达式避免部分匹配,替换为^Api.*(匹配所有以Api开头的站点,不限制后续字符)
  • 若需忽略大小写,可使用(?i)^Api.*
  • 确保配置格式正确,示例:
    iis:
      enabled: true
      sites:
        include:
          - "^Api.*"
    
  • 检查Windows Exporter版本,旧版本存在正则匹配bug,建议升级至最新稳定版

2. IIS站点白名单的格式说明

IIS模块的站点过滤支持精确匹配和正则匹配,配置在iis.sites.include或iis.sites.exclude数组中:

  • 精确匹配:直接填写站点全称,如- "Api商城站点"
  • 正则匹配:使用Go语法正则,常用示例:
    • 匹配所有包含Api的站点:- ".*Api.*"
    • 匹配以Api结尾的站点:- ".*Api$"
    • 匹配指定多个站点:- "^(ApiSite1|ApiSite2)$"
  • 优先级说明:exclude规则优先级高于include,即同时配置时,被exclude匹配的站点会被排除,即便在include列表中

3. 仅采集指定IIS指标的配置方法

Windows Exporter本身无法直接指定采集单个指标,需通过Prometheus的metric_relabel_configs过滤指标,仅保留目标指标。在Prometheus的prometheus.yml中添加如下配置:

scrape_configs:
  - job_name: 'windows_exporter'
    static_configs:
      - targets: ['<windows_exporter_ip>:9182']
    metric_relabel_configs:
      # 仅保留指定的两个指标
      - source_labels: [__name__]
        regex: 'windows_iis_requests_total|windows_iis_current_application_pool_state'
        action: keep
      # 丢弃所有其他指标
      - action: drop

若需在Windows Exporter侧减少采集量,可先仅启用IIS模块(关闭其他无关模块),再配合Prometheus过滤:

# Windows Exporter的config.yml
enabled_collectors:
  - iis
iis:
  enabled: true

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.26 13:44:58