PCA PCA Service Discovery & Targets 2 — Questions and Answers
Question 1: What is the effect of setting `honor_labels: true` in a Prometheus scrape config?
- Target-provided labels take precedence over server-side labels (Correct answer)
- Server-side labels always override target labels
- All labels are dropped and replaced with defaults
- Labels are merged alphabetically
Correct answer: Target-provided labels take precedence over server-side labels
When honor_labels is true, Prometheus keeps the labels exported by the target instead of overwriting them with its own labels.
Question 2: Which Prometheus SD mechanism discovers targets via DNS SRV records?
- dns_sd_configs (Correct answer)
- consul_sd_configs
- ec2_sd_configs
- file_sd_configs
Correct answer: dns_sd_configs
dns_sd_configs uses DNS SRV records to discover scrape targets dynamically.
Question 3: What is the purpose of the `__metrics_path__` label in Prometheus service discovery?
- It specifies the URL path on the target from which metrics are scraped (Correct answer)
- It defines the local filesystem path for metric storage
- It sets the Prometheus rule file path
- It names the remote_write endpoint
Correct answer: It specifies the URL path on the target from which metrics are scraped
The __metrics_path__ label overrides the default /metrics path used when scraping a specific target.
Question 4: When using Kubernetes service discovery, which role discovers individual pod endpoints rather than services?
- pod (Correct answer)
- endpoints
- service
- node
Correct answer: pod
The `pod` role in kubernetes_sd_configs discovers all running pods and exposes their container ports as scrape targets.
Question 5: How does Prometheus handle a target that becomes unreachable during service discovery?
- It marks it as DOWN and continues attempting to scrape on the next interval (Correct answer)
- It removes the target from its configuration permanently
- It triggers an immediate alert and stops scraping all targets
- It falls back to the last known good metric values
Correct answer: It marks it as DOWN and continues attempting to scrape on the next interval
Prometheus records scrape failures as UP=0 for the target and retries on the next scrape interval without removing it.
Question 6: Which relabel_configs action copies label values from one label name to another?
- replace (Correct answer)
- labelmap
- drop
- keep
Correct answer: replace
The `replace` action can copy a source label's value into a new target_label, effectively renaming or duplicating it.
What is the effect of setting `honor_labels: true` in a Prometheus scrape config?