Prometheus allows me to dynamically load targets with file_sd_config from a .json file like this
#prometheus.yaml
- job_name: 'kube-metrics'
file_sd_configs:
- files:
- 'targets.json'
[
{
"labels": {
"job": "kube-metrics"
},
"targets": [
"http://node1:8080",
"http://node2:8080"
]
}
]
However my targets differ in the metrics_path
and not the host (I want to scrape metrics for every kubernetes node on <kube-api-server>/api/v1/nodes/<node-name>/proxy/metrics/cadvisor
) but I can only set the metrics_path
at the job level and not per target. Is this even achievable with prometheus or do I have to write my own code to scrape all these metrics and export them at a single target. Also I couldn't find a list of all supported auto discovery mechanisms, did I miss something in the docs?
__metrics_path__
to the service discovery's scrape config would suffice. This way you don't need to relabel it. – Selfforgetful