Skip to main content

Prometheus Alerting Rule Generator

Generate a valid Prometheus alerting_rules.yaml from a PromQL expression, severity, for: duration and annotation templates — with correct YAML structure and quoting every time.

Input

How often Prometheus evaluates this group, e.g. 30s, 1m. Leave blank to use the global default.

Alert rule

How long the condition must hold before firing — a number + unit (ms, s, m, h, d, w, y). Leave blank to fire immediately.

One more rule per line, pipe-delimited: AlertName | expr | for | severity | summary | description — only the name and expression are required; the rest fall back to the primary rule's severity or are omitted.

Output

alerting_rules.yaml
 
Was this helpful?

Guides

What it does

The Prometheus Alerting Rule Generator turns a PromQL expression, a for: duration, a severity level and a pair of annotation templates into a ready-to-use alerting_rules.yaml file — the exact groups: → rules: → expr/for/labels/annotations shape promtool check rules expects.

Prometheus alert-rule YAML is strict about indentation, and PromQL expressions routinely contain characters — {, }, :, quotes — that break a hand-typed YAML scalar if they aren't quoted correctly. This tool builds the rule as structured data and lets a real YAML serializer handle the quoting, so the output is always valid regardless of what punctuation your expression or annotation text contains.

How to use it

  1. Set a rule group name (and an optional evaluation interval, e.g. 1m).
  2. Fill in the alert: name, PromQL expression, for: duration (how long the condition must hold before firing), severity, and the summary/description annotation templates — both support Go template variables like {{ $labels.instance }}.
  3. Copy or download the generated alerting_rules.yaml.

Adding more rules to the same group

Real rule files almost always group several alerts together. Add one more per line under Additional rules, pipe-delimited:

AlertName | PromQL expression | for | severity | summary | description

Only the name and expression are required — a line that omits for/severity/summary/description falls back to the primary rule's severity (or omits that field entirely). Lines starting with # are treated as comments and skipped.

What's a valid for: duration?

A number followed by a unit: ms, s, m, h, d, w, or y — e.g. 30s, 5m, 2h. Leave it blank to fire the alert immediately once the expression is true, with no waiting period.

Does this validate my PromQL expression?

No — it emits your expression into a correctly-quoted YAML scalar, but doesn't parse or check the query itself. To format or sanity-check a PromQL expression before pasting it in, use the PromQL Formatter.

What if I need to generate a ConfigMap to mount this file into a pod?

Use the Kubernetes ConfigMap / Secret Generator to wrap the generated YAML into a mountable ConfigMap.

Privacy

Everything runs in your browser — the group name, PromQL expressions and annotation text you enter are never sent anywhere.

alertmanagerpromqlmonitoringobservabilitysregrafanametrics alertnode exporter

Use it from code

From 3 credits per call

REST API

curl -X POST https://api.iotools.cloud/v1/tool/prometheus-alerting-rule-generator \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "groupName": "example-alerts",
    "interval": "1m",
    "alertName": "HighCpuUsage",
    "expr": "avg(rate(node_cpu_seconds_total{mode=\"idle\"}[5m]…",
    "forDuration": "5m",
    "severity": "critical",
    "summary": "{{ $labels.instance }}: high CPU usage",
    "description": "CPU idle time has been below 10% for more than 5…",
    "additionalRules": ""
  }'

Swap in your own key from your account. The tool's fields are the body — no wrapper.

Ask an AI agent

Use the IOTools `prometheus-alerting-rule-generator` tool (Prometheus Alerting Rule Generator) on this input:

YOUR_INPUT_HERE

Paste this at any agent connected to the IOTools MCP server, then add your input.

Love the tools? Lose the ads.

One payment clears every ad from your account, for good. No subscription, no tracking.