Different Prometheus scrape URL for every target

Viewed 49723

Every instance of my application has a different URL. How can I configure prometheus.yml so that it takes path of a target along with the host name?

scrape_configs:
- job_name:       'example-random'

# Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: 5s

static_configs:
  - targets: ['localhost:8090','localhost:8080']
    labels:
      group: 'dummy'
4 Answers

This is the configuration I used to get prometheus up and running.

Prometheus Endpoint : http://localhost:8080/appcontext/v1/actuator/prometheus

Configuration: Add the below config under /etc/prometheus/prometheus.yml

- job_name: 'appdev'
    scrape_interval: 5s
    metrics_path: /appcontext/v1/actuator/prometheus
    static_configs:
      - targets: ['localhost:8082'] 
        labels:
          group: 'appdev'

Related