How does Prometheus integrate with Kubernetes service discovery? [Intermediate]
Answer
Prometheus integrates with Kubernetes service discovery by watching Kubernetes API resources and turning pods, services, endpoints, EndpointSlices, nodes, and ingresses into scrape targets with metadata labels.
Technical explanation
Prometheus can use native kubernetes_sd_configs or higher-level Prometheus Operator objects.
Relabeling maps Kubernetes metadata into stable labels and filters targets based on annotations or selectors.
RBAC must allow Prometheus to list and watch the required resources.
Hands-on example
Example: with the Prometheus Operator, create a Service exposing port name 'metrics' and a ServiceMonitor selecting app='checkout'. Verify targets in Prometheus UI. If missing, check ServiceMonitor namespaceSelector, service labels, endpoint port name, and Prometheus serviceMonitorSelector.
Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.
More Observability interview questions
- What is the Prometheus Operator, and what are ServiceMonitor and PodMonitor? [Intermediate]
- What is the difference between Thanos and Cortex/Mimir at a high level? [Intermediate]
- How does Prometheus storage (TSDB) work, and what is the retention model? [Intermediate]
- How does Prometheus handle high cardinality, and why is it a problem? [Intermediate]
- What is an alerting rule, and how does it differ from a recording rule? [Basic]
- What is a recording rule, and when would you use one? [Basic]
- What is the Splunk data pipeline (input, parsing, indexing, search)? [Intermediate]
- How do you compute a 95th percentile latency from a histogram in PromQL (histogram_quantile)? [Basic]