# Multiple metics\_path for a single job

**URL:** <https://discuss.prometheus.io/t/multiple-metics-path-for-a-single-job/1930>\
**Category:** General Help/Support\
**Created:** [October 2, 2023, 9:06pm UTC](https://discuss.prometheus.io/t/multiple-metics-path-for-a-single-job/1930 "2023-10-02T21:06:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cookie-lgo](https://avatars.discourse-cdn.com/v4/letter/c/71c47a/32.png) [@cookie-lgo](https://discuss.prometheus.io/u/cookie-lgo)\
**Post date:** [October 2, 2023, 9:06pm UTC](https://discuss.prometheus.io/t/multiple-metics-path-for-a-single-job/1930/1 "2023-10-02T21:06:57Z")

</div>

Hello! I have multiple remote machines that are running both cadvisor and node-exporter. These machines are fairly locked down so I cannot open more ports on them to expose the external ports of the cadvisor and node-exporter containers. To get around opening ports, I setup a nginx proxy on every remote machine so I can proxy each requests from prometheus to cadvisor and node-exporter. I am wondering if I can specify multiple `metrics_path` for a single job. Heres an example of the idea as a prometheus config file.

```yaml
global:
  scrape_interval: 15s
  evaluation_interval: 15s

scrape_configs:
  - job_name: remote machine 1
    static_configs:
      - targets: ['remote_machine_1_ip:8080']
      - metrics_path: ['/metrics/cadvisor', '/metrics/nodeexporter']
 
  - job_name: remote machine 2
    static_configs:
      - targets: ['remote_machine_2_ip:8080']
      - metrics_path: ['/metrics/cadvisor', '/metrics/nodeexporter']

  - job_name: remote machine 3
    static_configs:
      - targets: ['remote_machine_3_ip:8080']
      - metrics_path: ['/metrics/cadvisor', '/metrics/nodeexporter']

```

[I believe this question is asking pretty much the same thing.](https://discuss.prometheus.io/t/how-to-create-a-second-target-for-a-job-with-just-a-param-changed/1900)  
Please let me know if I can provide anymore info or if im not being clear in what im asking, thank you!

---

<div class="post-metadata">

**Author:** ![salessandri](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.prometheus.io/salessandri/32/814_2.png) [@salessandri](https://discuss.prometheus.io/u/salessandri)\
**Post date:** [October 3, 2023, 1:50pm UTC](https://discuss.prometheus.io/t/multiple-metics-path-for-a-single-job/1930/2 "2023-10-03T13:50:27Z")

</div>

Achieving what you are trying to achieve is possible but I would change the approach. Instead of defining a job per machine, I would opt to define a job per scraping type (cAdivsor, node\_exporter). One can only set a path per scrape config, but multiple hosts per scrape config - it was also aimed to be used in that way.

So something like this:

```auto
scrape_configs:
  - job_name: cAdvisor
  	 metrics_path: /metrics/cadvisor
    static_configs:
      - targets: ['remote_machine_1_ip:8080', 'remote_machine_2_ip:8080']
  - job_name: node_exporter
  	 metrics_path: /metrics/nodeexporter
    static_configs:
      - targets: ['remote_machine_1_ip:8080', 'remote_machine_2_ip:8080']

```

---

<div class="post-metadata">

**Author:** ![cookie-lgo](https://avatars.discourse-cdn.com/v4/letter/c/71c47a/32.png) [@cookie-lgo](https://discuss.prometheus.io/u/cookie-lgo)\
**Post date:** [October 4, 2023, 2:15pm UTC](https://discuss.prometheus.io/t/multiple-metics-path-for-a-single-job/1930/3 "2023-10-04T14:15:39Z")

</div>

Ah i see, this works perfectly. Thank you!

---

<div class="post-metadata">

**Author:** ![valyala](https://dub1.discourse-cdn.com/flex017/user_avatar/discuss.prometheus.io/valyala/32/821_2.png) [@valyala](https://discuss.prometheus.io/u/valyala)\
**Post date:** [November 28, 2023, 1:36pm UTC](https://discuss.prometheus.io/t/multiple-metics-path-for-a-single-job/1930/4 "2023-11-28T13:36:06Z")

</div>

See also [kubernetes - prometheus dynamic metrics\_path - Stack Overflow](https://stackoverflow.com/questions/59866342/prometheus-dynamic-metrics-path)
