Multiple metics_path for a single job

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.

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.
Please let me know if I can provide anymore info or if im not being clear in what im asking, thank you!

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:

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']
2 Likes

Ah i see, this works perfectly. Thank you!

See also kubernetes - prometheus dynamic metrics_path - Stack Overflow