Interview Prep/SRE & Reliability/Prometheus SLIs & Recording Rules

Your new ServiceMonitor is applied, but the service never appears under Status → Targets.

BeginnerTroubleshootingPrometheus SLIs & Recording Rules
Answer

Likely causes → ServiceMonitor not selected by the Prometheus resource (labels or namespace selector), its selector.matchLabels does not match the Service labels, or endpoints.port refers to a port name the Service does not define.

Diagnose →

kubectl get servicemonitor -n shop checkout -o yaml | yq '.spec'
kubectl get svc -n shop checkout -o yaml | yq '.metadata.labels, .spec.ports'
kubectl get prometheus -n monitoring -o jsonpath='{.items[0].spec.serviceMonitorSelector}'

Fix → Match labels exactly, use the named Service port (port: http), and add the release label or set serviceMonitorSelectorNilUsesHelmValues=false.

Prevent → Ship a ServiceMonitor in the service Helm chart template, tested in CI against a kind cluster.

All SRE & Reliability questions Roadmap: SRE & incident response

More on Prometheus SLIs & Recording Rules