Different Prometheus scrape URL for every target

You currently can’t configure the metrics_path per target within a job but you can create separate jobs for each of your targets so you can define metrics_path per target.

Your config file would look something like this:

scrape_configs:
- job_name:       'example-target-1'
  scrape_interval: 5s
  metrics_path: /target-1-path-to-metrics
  static_configs:
    - targets: ['localhost:8090']
      labels:
        group: 'dummy'

- job_name:       'example-target-2'
  scrape_interval: 5s
  metrics_path: /totally-different-path-for-target-2
  static_configs:
    - targets: ['localhost:8080']
      labels:
        group: 'dummy-2'

Leave a Comment