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: 30s
Then confirm the target appears under Status -> Targets.
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 observability, and how is it different from traditional monitoring? [Basic]
- What are the three pillars of observability (metrics, logs, traces)? [Basic]
- What is the difference between monitoring and observability in practice? [Basic]
- What are the four golden signals of monitoring? [Basic]
- What is the difference between the USE method and the RED method? [Basic]
- When would you use the USE method versus the RED method? [Basic]
- What is an SLI, an SLO, and an SLA, and how do they relate? [Basic]
- How do you choose good SLIs for a service? [Basic]