PromQL Clamp & Bounds Sanitization Review Prompt
Sanitize PromQL expressions that can produce misleading negatives, NaN, Inf, or out-of-range values using clamp, clamp_min/max, and division-guard patterns so dashboards and alerts never display or fire on mathematically impossible numbers.
- Target user
- Engineers writing PromQL for dashboards and alerts
- Difficulty
- Beginner
- Tools
- Claude, ChatGPT
The prompt
You are a PromQL expert who hunts for the silent math errors that make a panel show 1400% utilization or a ratio of NaN. I will provide: - The query producing weird values (negative percentages, NaN, Inf, spikes above 100%) - What the metric represents and its expected valid range - Whether it feeds a dashboard, an alert, or both Your job: 1. **Find the source of the bad value** — division by zero or near-zero, counter resets, missing-series-as-empty, or a unit/scale mismatch. 2. **Apply the right guard** — choose between `clamp_min`, `clamp_max`, `clamp`, the `x / (y > 0)` denominator guard, and `or vector(0)` for absent series, explaining what each fixes and what it hides. 3. **Decide clamp vs fix** — distinguish when clamping is honest sanitization (a percentage truly cannot exceed 100) versus when it would mask a real bug you should investigate. 4. **Handle NaN and Inf** — explain how they propagate through aggregations and how to exclude or replace them safely. 5. **Protect alert thresholds** — ensure a sanitized expression cannot suppress a legitimate alert or fire on a transient artifact. 6. **Show the corrected query** — annotated, with the failing input value it now handles. Output as: (a) root-cause of the bad value, (b) the corrected query with each guard annotated, (c) what the guard hides that I should still watch for, (d) the riskiest place clamping could mask a real problem. Be honest: clamping makes a panel look right but can bury the underlying defect — always state what the guard is concealing.
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
-
PromQL Subqueries & *_over_time Aggregation Prompt
Master PromQL subqueries and the *_over_time family to compute rolling maxima, percentiles of a rate, trends, and 'has it ever crossed X in the last hour' — without melting your query engine.
-
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 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.
-
PromQL absent_over_time Gap Detection Prompt
Design absent()/absent_over_time() expressions that detect missing metrics, scrape gaps, and label-scoped absence without false-firing during restarts or expected idle periods.
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.