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

Prometheus got OOMKilled after a developer added a `user_id` label to `http_requests_total`.

IntermediateTroubleshootingPrometheus SLIs & Recording Rules
Answer

Likely causes → Cardinality explosion: one series per user x route x code x pod.

Diagnose →

topk(10, count by (__name__) ({__name__=~".+"}))
count(count by (user_id) (http_requests_total))

Also check prometheus_tsdb_head_series before and after the deploy.

Fix → Drop the label at scrape time while the code is fixed:

metricRelabelings:
  - action: labeldrop
    regex: user_id

Then remove it from the instrumentation; per-user data belongs in logs or traces.

Prevent → Set sampleLimit on ServiceMonitors, alert on head series growth, and review metric labels in code review.

All SRE & Reliability questions Roadmap: SRE & incident response

More on Prometheus SLIs & Recording Rules