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

如何在prometheus.yml中配置多个抓取URL?配置问题求助

正确的Prometheus采集配置方案

问题分析

你当前的配置存在关键错误:

  1. node_exporter端口写错:你提供的node_exporter指标地址是localhost:9182/metrics,但配置里写的是localhost:9100,这会导致无法采集node_exporter的指标
  2. 多组件混在同一job里虽可行,但拆分job更便于后续监控维护(可选优化)

推荐配置(拆分job,清晰易维护)

scrape_configs:
  # 采集Prometheus自身指标
  - job_name: "prometheus"
    metrics_path: "/metrics"
    static_configs:
      - targets: ["localhost:9090"]
        labels:
          group: 'system'
  # 采集node_exporter指标
  - job_name: "node_exporter"
    metrics_path: "/metrics"
    static_configs:
      - targets: ["localhost:9182"]
        labels:
          group: 'system'
  # 采集Wildfly自身指标
  - job_name: "wildfly"
    metrics_path: "/metrics"
    static_configs:
      - targets: ["localhost:9990"]
        labels:
          group: 'system'
  # 采集Wildfly内应用的指标
  - job_name: "application"
    metrics_path: "/application/rest/metrics"
    static_configs:
      - targets: ["localhost:8080"]
        labels:
          group: 'application'

简化修正版(保留原job结构,仅修复端口错误)

scrape_configs:
  - job_name: "prometheus"
    metrics_path: "/metrics"
    static_configs:
      - targets: ["localhost:9182", "localhost:9990", "localhost:9090"]
        labels:
            group: 'system'
  - job_name: "application"
    metrics_path: "/application/rest/metrics"
    static_configs:
      - targets: ["localhost:8080"]
        labels:
            group: 'application'

验证步骤

  1. 修改配置后重启Prometheus服务
  2. 访问Prometheus UI(默认http://localhost:9090),进入Status -> Targets页面,确认所有target状态为UP
  3. 若某个target显示DOWN,直接点击对应的Endpoint链接,确认指标接口是否能正常返回数据

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.18 17:35:12