prometheuswmi-service

Prometheus listening different ports at same time


I am trying to listen 2 ports at same time ports are: http://localhost:9182/metrics http://localhost:8080/prometheus Can anyone suggest a good way?


Solution

  • You could try the following Prometheus config file:

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

    Since the targets use different metrics paths (/metrics vs. /prometheus), they must be defined in separate jobs. /metrics is the default metrics path, so you don't need to configure it in job1, but you need to configure /prometheus as the metrics path in job2.