Prometheus Alert Rule Generator Prompt
Generate production-quality Prometheus alerting rules with sensible thresholds, labels, and runbook annotations.
- Target user
- SREs and platform engineers writing Prometheus alerting rules
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior SRE who writes Prometheus alerting rules used in production by on-call engineers. Generate a Prometheus alert rule in YAML for the scenario I describe. Requirements: 1. Use a PromQL expression that is resilient to short blips (rate(...)[5m], avg_over_time, etc.). 2. Include `for:` duration appropriate to the signal (avoid alert flapping). 3. Set `severity` label (critical | warning | info) and any other useful labels (`team`, `service`, `runbook`). 4. Write an `annotations.summary` (short, scannable in PagerDuty) and `annotations.description` (full context for the on-call). 5. Include `annotations.runbook_url` placeholder. 6. Explain in 2–3 sentences why this threshold and `for:` window are reasonable. 7. List 2–3 ways this alert could produce false positives and how to mitigate them. Scenario: [DESCRIBE THE THING TO ALERT ON] SLO target (if any): [e.g. 99.9% over 30d] Service tier: [tier-1 / tier-2 / tier-3] Existing labels available: [list metric labels, e.g. service, env, region, cluster]
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Why this prompt works
Generic alert generators produce alerts that flap, page at 3am for nothing, or — worse — silently miss real outages. This prompt anchors generation in production realities: appropriate for: windows, severity routing, false-positive analysis, and runbook annotations.
How to use it
- Pick a clear scenario: “alert when API p99 latency exceeds 800ms” beats “alert on latency.”
- Tell the model what labels actually exist on your metrics. Otherwise it will invent label names.
- Paste the generated YAML into a file and run
promtool check rules <file>.
Example expected output
- alert: HighApiP99Latency
expr: |
histogram_quantile(0.99,
sum by (le, service) (rate(http_request_duration_seconds_bucket{service="api"}[5m]))
) > 0.8
for: 10m
labels:
severity: warning
team: platform
service: api
annotations:
summary: "API p99 latency > 800ms on {{ $labels.service }}"
description: "p99 latency has exceeded 800ms for 10 minutes…"
runbook_url: "https://runbooks.example.com/api-latency" Related prompts
-
Grafana Dashboard Query Builder Prompt
Generate PromQL and Grafana panel JSON for service dashboards (RED, USE, golden signals).
-
Incident Postmortem Drafter Prompt
Convert raw incident notes, Slack threads, and timelines into a blameless postmortem draft.
-
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.
-
PromQL Anomaly Detection & Z-Score Alerting Prompt
Build statistical anomaly-detection alerts in pure PromQL — z-score deviation from a rolling baseline, week-over-week seasonal comparison, and MAD-based outlier detection — so you catch weird behavior static thresholds miss.
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.