普罗米修斯同时监听不同的端口

Prometheus listening different ports at same time

我正在尝试同时监听 2 个端口端口是: http://localhost:9182/metrics http://localhost:8080/prometheus 谁能推荐个好方法?

您可以尝试以下方法Prometheus config file

scrape_configs:
  - job_name: job1
    static_configs:
      - targets:
        - localhost:9182
  - job_name: job2
    metrics_path: /prometheus
    static_configs:
      - targets:
        - localhost:8080

由于目标使用不同的指标路径(/metrics/prometheus),因此必须在单独的作业中定义它们。 /metrics是默认的metrics路径,所以在job1中不需要配置,但是在job2中需要配置/prometheus作为metrics路径。