I have 2 different prometheus server (with its set of alertmanager, pushgateway, nodeExporter and kube-state-metrics)
When I port forward either of these 2 servers, in their respective /targets - I find combined details for the below job_name(s) :
- kubernetes-nodes (20/20 up)
- kubernetes-nodes-cadvisor (20/20 up)
- kubernetes-pods (90/90 up)
- kubernetes-service-endpoints (78/78 up)
- prometheus-pushgateway (2/2 up)
- prometheus (1/1 up)
- kubernetes-apiservers (1/1 up)
My values.yaml file (different for both servers) contains the following part -
prometheus:
serverFiles:
prometheus.yml:
rule_files:
- /etc/config/recording_rules.yml
- /etc/hcp/config/alerting_rules.yml
scrape_configs:
- job_name: prometheus
static_configs:
- targets:
- localhost:9090 #exposing metrics
I want to ensure that for prometheus-server-1 should only scrape details related to it and same goes with prometheus-server-2, & have only their details in their /targets despite having the same default ports used by prometheus.
While going through all the prometheus docs and experimenting different ways, finally am able to get through to have prometheus-server scraping data only related to it, hence answering my own question.
This can be achieved by adding relabel_configs condition in the respective jobs under values.yaml file shared above.
Example for job_name: prometheus-pushgateway:
**NOTE: scrape_configs overwrites all the default scrape_configs, so kindly include all default statements while adding your specific conditions to it.
For additional info, below links can be helpful: