Prometheus Query API Read-Path Protection Prompt
Protect the Prometheus query API from runaway, expensive, or hostile queries using sample/time limits, query logging, timeouts, and a fronting proxy so one bad dashboard or ad-hoc query cannot OOM or stall the whole instance.
- Target user
- SREs whose Prometheus is shared by many query clients
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior observability engineer who has watched a single unbounded query take down a Prometheus serving fifty teams. I will provide: - My Prometheus version and who queries it (Grafana, ad-hoc users, automation, federation) - Symptoms (OOM, slow queries, high CPU, querier timeouts) and any current flags set - Whether a proxy or query frontend sits in front of it Your job: 1. **Set the guardrail flags** — explain `--query.max-samples`, `--query.timeout`, `--query.max-concurrency`, and `--query.lookback-delta`, and recommend values for my load. 2. **Find the offenders** — enable and read the active query log and `--query.log-file` to identify the heaviest queries by samples and duration. 3. **Front the read path** — design a proxy layer (or query frontend) that enforces per-tenant limits, time-range caps, and result caching the core binary cannot do alone. 4. **Tame the clients** — fix the dashboard/automation patterns that cause expensive scans: huge ranges, tiny steps, regex-heavy matchers, unbounded subqueries. 5. **Isolate ad-hoc from critical** — separate the alerting/recording read path from human exploration so exploration cannot starve rule evaluation. 6. **Verify the protection** — propose a load test that fires a known-expensive query and confirms it is rejected or bounded, not fatal. Output as: (a) a recommended flag set with values and rationale, (b) the proxy/frontend design, (c) the top query anti-patterns to fix, (d) the single change with the largest protective payoff. Caution: aggressive limits can reject legitimate large queries — tune thresholds against real query shapes rather than guessing, and communicate the caps to query owners.
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
-
Prometheus Query Log Slow-Query Audit Prompt
Enable and analyze the Prometheus active query log and query_log_file to find expensive PromQL queries that strain the server, then rewrite or offload them.
-
Prometheus Meta-Monitoring & Self-SLO Design Prompt
Build the monitoring-of-the-monitoring layer: alerts and SLOs that tell you when Prometheus itself is unhealthy — scrapes lagging, rules failing, WAL growing, or the whole instance dead — so your blind spots do not become silent outages.
-
Prometheus Recording Rule Layered Aggregation Prompt
Design a tiered hierarchy of recording rules — raw to job-level to service-level — that precompute hot aggregations once and reuse them, cutting dashboard and alert query cost without creating stale or circular rule dependencies.
-
Grafana k6 Load Test Metrics Dashboard Prompt
Stream k6 load-test results into Prometheus and build a Grafana dashboard that correlates virtual-user load, latency percentiles, error rates, and system saturation during a test run.
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.