PCA PCA Service Discovery & Targets 1 — Questions and Answers
Question 1: Which Prometheus configuration block defines how targets are discovered dynamically in a Kubernetes cluster?
- scrape_configs with kubernetes_sd_configs (Correct answer)
- alerting_rules with k8s selectors
- remote_write with cluster endpoints
- recording_rules with pod labels
Correct answer: scrape_configs with kubernetes_sd_configs
The scrape_configs block with kubernetes_sd_configs enables Prometheus to dynamically discover targets in a Kubernetes cluster.
Question 2: What is the purpose of the `relabel_configs` section in a Prometheus scrape job?
- To rewrite or filter target labels before scraping (Correct answer)
- To define alerting thresholds for discovered targets
- To configure remote storage destinations
- To set scrape intervals per metric
Correct answer: To rewrite or filter target labels before scraping
relabel_configs lets you rewrite, drop, or keep target labels before Prometheus scrapes them.
Question 3: Which action in relabel_configs drops a target entirely from the scrape list?
- drop (Correct answer)
- keep
- replace
- labelmap
Correct answer: drop
The `drop` action in relabel_configs removes a target if the source label value matches the specified regex.
Question 4: In Prometheus file-based service discovery, which file format is used to define static targets?
- JSON or YAML (Correct answer)
- TOML only
- CSV
- XML
Correct answer: JSON or YAML
File-based service discovery (file_sd_configs) reads target definitions from JSON or YAML files.
Question 5: What does the `__address__` label represent in Prometheus service discovery?
- The host:port of the scrape target (Correct answer)
- The metric namespace prefix
- The Prometheus server's own address
- The alertmanager endpoint
Correct answer: The host:port of the scrape target
The __address__ label holds the host:port string that Prometheus will use to scrape a target.
Question 6: Which service discovery mechanism allows Prometheus to discover targets registered in HashiCorp Consul?
- consul_sd_configs (Correct answer)
- dns_sd_configs
- http_sd_configs
- static_configs
Correct answer: consul_sd_configs
consul_sd_configs integrates Prometheus with HashiCorp Consul to dynamically discover services registered there.
Which Prometheus configuration block defines how targets are discovered dynamically in a Kubernetes cluster?