Create an alert rule
Step-by-step rule builder: aggregation, condition, severity, routing, recipes.
alertsruleaggregationseveritycondition
Create an alert rule (step by step)
Go to Alerts → Rules → Create Rule. A rule turns a metric/condition into routed alerts.
- Name and description — make it actionable (what's wrong and where).
- Source / scope — choose the application, service, synthetic test or metric to watch.
- Aggregation — pick the function:
avg(),count(),countIf(), or a percentile (95th/99th), over an evaluation window. - Condition — the comparison and threshold (e.g. p95 > 800ms; success rate < 99%). Combine conditions with AND.
- Severity — critical / warning / info; this drives routing and urgency.
- For — how long it must hold before firing (avoids flapping).
- Notifications — channels/people per severity (Slack, email, PagerDuty…).
- Save. The rule starts evaluating immediately.
Three different clocks — don't mix them up. The window your query looks at (e.g. p95 over the last 5 minutes) lives in the condition itself. Evaluation Interval (default 5 minutes) is how often the rule runs. For Duration (default 0) is how long the breach must persist before an alert is created — 0 fires on the first breaching evaluation. Worst-case time to page is roughly evaluation interval + for duration.
Worked example: checkout p95 over 800 ms for 5 minutes
Goal: warn when the checkout service's p95 latency stays above 800 ms for 5 minutes, without paging on a single slow blip.
| Field | Value |
|---|---|
| Name | checkout p95 latency > 800ms |
| Source / scope | service checkout |
| Aggregation | 95th percentile of duration |
| Condition | > 800 ms |
| Severity | warning |
| Evaluation Interval (minutes) | 1 |
| For Duration (minutes) | 5 |
| Notifications | Slack #checkout-oncall |
Expected behavior: the rule evaluates every minute; the first breaching minute puts it in pending; if p95 stays above 800 ms for 5 consecutive minutes it fires once to Slack, and a brief spike that recovers within the window never alerts.
Condition recipes
| Goal | Aggregation + condition |
|---|---|
| Latency budget | p95(duration) > 800ms for 5m → warning |
| Error surge | countIf(status=error)/count() > 2% → critical |
| Availability SLO | success rate < 99.9% → critical |
| Silent source | count() == 0 over 5m (absence) → warning |
Evaluation is distributed and de-duplicated, so one underlying problem yields one alert, not one per replica.