Interview Prep/Monitoring & Observability/Prometheus storage, memory and cardinality

A query fails with `query processing would load too many samples into memory in query execution`

IntermediateTroubleshootingPrometheus storage, memory and cardinality
Answer

Likely causes → The query touches more samples than --query.max-samples (default 50,000,000), usually a long range over a high-cardinality metric with a small step.

Diagnose → Re-run with a shorter range and check count(<selector>) to see the series count.

Fix → Add label filters, aggregate earlier (sum by (job) (rate(...))), use a recording rule, or increase the step. Raise the limit only if memory allows.

Prevent → Back expensive dashboard panels with recording rules.

All Monitoring & Observability questions Roadmap: Monitoring & alerting

More on Prometheus storage, memory and cardinality