What is the Prometheus Operator, and what are ServiceMonitor and PodMonitor? [Intermediate]
Answer
The Prometheus Operator manages Prometheus, Alertmanager, and related configuration as Kubernetes custom resources. ServiceMonitor and PodMonitor define how Prometheus discovers and scrapes service endpoints or pods.
Technical explanation
ServiceMonitor is usually preferred when a stable Service fronts application pods.
PodMonitor is useful when scraping pods directly, such as sidecars, daemon workloads, or jobs without a service.
The Operator converts these custom resources into Prometheus scrape configuration.
Hands-on example
ServiceMonitor example:
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: checkout
spec:
selector:
matchLabels:
app: checkout
endpoints:
- port: metrics
interval: 30sThen confirm the target appears under Status -> Targets.
Preparing for an interview?
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
- How does Prometheus integrate with Kubernetes service discovery? [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 the Splunk data pipeline (input, parsing, indexing, search)? [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 difference between a Splunk forwarder, indexer, and search head? [Intermediate]