PCA PCA Service Discovery & Configuration 1 — Questions and Answers
Question 1: Which Prometheus service discovery mechanism discovers targets using Kubernetes API watch calls?
- file_sd_config
- kubernetes_sd_config (Correct answer)
- dns_sd_config
- http_sd_config
Correct answer: kubernetes_sd_config
`kubernetes_sd_config` uses the Kubernetes API to discover pods, services, endpoints, ingresses, and nodes as scrape targets.
Question 2: In Prometheus file-based service discovery, what file formats are supported?
- JSON only
- YAML only
- JSON and YAML (Correct answer)
- CSV and JSON
Correct answer: JSON and YAML
Prometheus `file_sd_config` accepts target group files written in either JSON or YAML format.
Question 3: How frequently does Prometheus reload file-based service discovery files by default?
- 5 seconds
- 30 seconds
- 5 minutes
- Immediately via inotify/fsnotify (Correct answer)
Correct answer: Immediately via inotify/fsnotify
Prometheus uses filesystem notifications (inotify on Linux) to detect file_sd file changes and reloads them immediately without waiting for a timer.
Question 4: What is the purpose of the `relabel_configs` section in a Prometheus scrape_config?
- Rename metric names before storage
- Transform or filter discovered target labels before scraping (Correct answer)
- Rewrite alert labels before sending to Alertmanager
- Encode labels for remote write
Correct answer: Transform or filter discovered target labels before scraping
`relabel_configs` runs a pipeline of label transformations on discovered target metadata, controlling which targets are scraped and how they are labeled.
Question 5: Which relabeling action drops a target so Prometheus does not scrape it?
- keep
- drop (Correct answer)
- labelmap
- replace
Correct answer: drop
The `drop` action in relabel_configs causes Prometheus to skip any target whose labels match the configured regex.
Question 6: What meta-label does Prometheus kubernetes_sd_config expose for a pod's namespace?
- __meta_kubernetes_namespace
- __meta_kubernetes_pod_namespace (Correct answer)
- __meta_kubernetes_pod_label_namespace
- __meta_k8s_ns
Correct answer: __meta_kubernetes_pod_namespace
`__meta_kubernetes_pod_namespace` is the meta-label containing the Kubernetes namespace of a discovered pod target.
Which Prometheus service discovery mechanism discovers targets using Kubernetes API watch calls?