Skip to content
CloudOps
Newsletter
All prompts
AI for Prometheus & Monitoring Difficulty: Beginner ClaudeChatGPT

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.
Newsletter

Free: the DevOps AI Incident-Triage Cheat Sheet

Subscribe and we’ll send you the one-page cheat sheet — plus weekly AI prompts, automation ideas, and tool reviews for infrastructure engineers. One email a week. No spam, unsubscribe anytime.

  • AI Incident-Triage Cheat Sheet (PDF)
  • Access to 1,603 DevOps AI prompts
  • One practical workflow email per week