I have a quit large list of hosts that I'm monitoring through Prometheus. For each host I have a couple of different end-points where I fetch metrics but it feels like a lot of repeating in the Prometheus-configuration .yml-file:
job_name: job1
static_configs:
- targets: [host1:9100, host2:9100, host3:9100, ... , host50:9100]
job_name: job2
static_configs:
- targets: [host1:9101, host2:9101, host3:9101, ... , host50:9101]
job_name: job3
static_configs:
- targets: [host1:9102, host2:9102, host3:9102, ... , host50:9102]
Is there a way in the Prometheus configuration to create a group of hosts and then for each job just specify that group and then a port/metric-path?
I.e. something like - host_targets: [host1, host2, host3, ... , host50]
- job_name: job1
- port: 9100
static_configs:
- targets: {{host_targets}}
- job_name: job2
- port: 9101
static_configs:
- targets: {{host_targets}}
- job_name: job3
- port: 9102
static_configs:
- targets: {{host_targets}}