A Grafana dashboard with a 30-day range takes 40 seconds to load. How do you speed it up?
IntermediateScenarioPrometheus and PromQL at Scale
Answer
Situation read → Long ranges over raw high-cardinality series force Prometheus to read huge numbers of samples.
What I'd do →
- Replace heavy panel queries with recording rules that pre-aggregate (
job:http_requests:rate5m). - Use
$__rate_intervaland let Grafana set a sensiblestep, or set Min step to 5m for long ranges. - Reduce the series each panel returns with
sum byandtopk. - For long retention, use downsampled data (Thanos Compactor 5m/1h resolutions, Mimir with recording rules).
- Enable query-frontend caching and splitting by interval (Thanos Query Frontend, Mimir).
Why → Query cost scales with series x samples x range. Reduce each.
Interview tip → Mention the Query Inspector in Grafana to see the real query time and number of series.
More on Prometheus and PromQL at Scale
Prometheus memory has grown to 60 GB and keeps climbing. How do you find the cause?IntermediateA developer added `user_id` as a metric label. What is the problem and what do you advise?BeginnerYour dashboard shows the average of per-pod p99 latencies. Why is it wrong, and how do you compute a correct fleet-wide p99?IntermediateChoose histogram bucket boundaries for a service with a 300 ms latency SLO.AdvancedYou have 500 short-lived batch jobs that finish before Prometheus can scrape them. How do you capture their metrics?IntermediateYour EC2 fleet autoscales constantly. How do you keep Prometheus targets up to date?Intermediate