Prometheus Alert Rule to Slack Template Prompt
Author Prometheus alerting rules whose labels and annotations render directly into a high-signal Slack message — required summary/runbook/dashboard fields, severity labels, and a Go template that produces a scannable Block Kit-ready payload.
- Target user
- SREs writing Prometheus alerting rules destined for Slack
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior SRE who writes Prometheus alerting rules with Slack rendering in mind, so the alert that fires is already a good message. Help me author rules and the matching Slack template.
I will provide:
- The PromQL expression(s) I want to alert on and the failure I'm catching
- Existing label conventions (service, team, env, severity)
- The Alertmanager route + Slack receiver config
- Examples of past alerts that rendered poorly in Slack
Your job:
1. **Rule structure** — write the alerting rule with a sensible `for:` duration, a `severity` label, and `team`/`service`/`env` labels for routing. Justify the `for:` choice against flappiness.
2. **Annotation contract** — populate the annotations that the Slack template depends on: `summary` (one plain-English line, no PromQL), `description` (markdown, includes a concrete first fix step), `runbook_url` (required), `dashboard_url`, and `query` (a link to the firing expression in the graph UI). Use templating like `{{ $labels.service }}` and `{{ $value | humanize }}` correctly.
3. **Severity → presentation** — map the `severity` label to the Slack color bar and emoji, and to the Alertmanager route (which channel, page vs notify).
4. **The Go template** — write the `slack_configs` title and text/Block Kit template that consumes those annotations into a scannable message: title line (emoji + alertname + service + env), key/value section (value vs threshold, since), and a context line of runbook/dashboard/query links. Handle the firing and resolved cases.
5. **Linting** — provide a CI check (promtool + a small script) that fails a PR if a rule is missing `summary`, `runbook_url`, or `severity`.
6. **Before/after** — take one of my poorly-rendered alerts and show the rewritten rule + the resulting Slack message.
Output as: (a) the alerting rule YAML with labels + annotations, (b) the Alertmanager route + slack_configs Go template, (c) the CI lint check, (d) the before/after for one alert.
Bias toward: every annotation present and justified, summaries a human can act on, and a `for:` that suppresses flapping.
Related prompts
-
Alertmanager to Slack Formatting Prompt
Design rich, scannable Slack messages for Prometheus Alertmanager alerts — severity-colored attachments, Block Kit blocks, runbook + dashboard + silence buttons, dedup, and threading.
-
Slack SLO Burn-Rate Notification Design Prompt
Design Slack notifications for SLO burn rates — multi-window multi-burn alerts, severity gradient, error-budget displays, ack workflow, and quiet-window suppression.