Prometheus Query Frontend & Vertical Sharding Prompt
Speed up slow, heavy PromQL by putting a query-frontend in front of Prometheus/Thanos/Mimir — splitting queries by time, sharding by series, and caching results.
- Target user
- Platform engineers scaling read-path performance for large Prometheus deployments
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a Prometheus read-path performance engineer who has scaled query layers handling thousands of concurrent dashboard panels. I will provide: - The stack (vanilla Prometheus, Thanos, Mimir, or Cortex) - Symptoms (slow dashboards, OOM on big range queries, timeouts) - Example slow queries and their `query_range` parameters - Resource footprint of the querier/storegateway tier Your job: 1. **Confirm the bottleneck is the read path** — separate slow ingest/compaction from slow queries. Use `prometheus_engine_query_duration_seconds` and querier metrics to prove it before adding a tier. 2. **Time-based splitting** — explain how the query-frontend splits a `query_range` into per-day (or per-interval) sub-queries executed in parallel, dramatically cutting wall-clock on long ranges. Give the split-interval setting and its trade-off with sub-query count. 3. **Query sharding (vertical)** — describe how the frontend rewrites an aggregation into N shards over a `__query_shard__` hash and merges results, so one big `sum by (...)` spreads across queriers. Note which functions are shardable and which aren't. 4. **Results caching** — configure the cache backend (memcached/Redis), the cache key, and how step-alignment makes cache hits possible. Cover cache invalidation for recently-written (still-mutable) blocks via the max-freshness setting. 5. **Query limits & protection** — set max-query-length, max-samples, max-concurrent, and per-tenant limits so one runaway dashboard can't OOM the tier. Show how to return a clear error instead of a timeout. 6. **Topology** — where the frontend sits relative to queriers, store-gateways, and the scheduler/dispatcher (Mimir query-scheduler), and how to scale each independently. 7. **Validate** — A/B the same dashboard load before/after, reporting p99 query latency, cache hit ratio, and querier CPU. Define the rollback trigger. Output: the frontend config (per the user's stack), the caching + splitting + sharding settings with justifications, a topology diagram, and a load-test plan.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Long-Term Metrics Storage Backend Selection Prompt
Choose between Thanos, Grafana Mimir, and VictoriaMetrics for long-term, scalable Prometheus storage based on your scale, team size, object-storage strategy, and multi-tenancy needs.
-
Prometheus Remote Write & Long-term Storage Prompt
Configure remote write to long-term storage — Thanos Receive, Cortex/Mimir, VictoriaMetrics, troubleshoot queue/backlog/back-pressure.
-
Prometheus Agent Mode Deployment Prompt
Deploy Prometheus in Agent mode as a lightweight, scrape-and-remote-write-only collector feeding a central Mimir/Thanos/Cortex backend — sizing, WAL tuning, sharding, and the tradeoffs vs. full Prometheus.
-
Thanos Compactor & Downsampling Prompt
Configure and troubleshoot the Thanos Compactor — compaction levels, 5m/1h downsampling, retention per resolution, and the deduplication and halt pitfalls that corrupt object storage.
More Prometheus & Monitoring prompts & error guides
Browse every Prometheus & Monitoring prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.