Alerting
Алертинг
Alerting automatically notifies the people responsible for a system when something needs attention. For example, it can page the on-call engineer when customers are repeatedly unable to check out.
What alerting does
A dashboard tells you what is happening when you look at it. Alerting tells you when you need to look. It turns signals such as failed requests, delayed jobs, or unsuccessful health checks into notifications that reach the team responsible for responding.
An alert is a condition the system has detected; a notification is a message about that condition. The distinction matters during an outage: twenty alerts from different instances can become one notification, and a single unresolved alert can lead to several reminders.
From signal to notification
An alert rule evaluates data from a source such as a metric, a log query, or a synthetic check that periodically tries a user action. The rule can fire on one failed check or wait until a condition has held for a specified duration. Waiting filters out brief spikes, but it also adds detection time.
Once the rule fires, a notification system routes the alert according to labels such as service, environment, and severity. In a Prometheus setup, Prometheus evaluates the rule, while Alertmanager handles routing, grouping, and deduplication. It can also silence notifications for scheduled maintenance without changing what the rule detects.
Example: a checkout API
Suppose a rule evaluates the share of checkout requests returning HTTP 5xx every minute. It uses a rolling five-minute window and fires if the error share is above 2%, there is enough traffic to make the ratio useful, and the condition remains true for three minutes. The five-minute window controls which requests count toward the ratio; the three-minute duration controls how long the rule must keep seeing a breach.
If the impact warrants an immediate response, the notification pages the on-call engineer. It should name the affected service and environment, show the observed error rate, and point to a dashboard and a runbook. The runbook might start by comparing the rise in errors with recent deployments. The alert identifies a symptom; it does not establish that a deployment caused it.
What makes an alert worth sending?
Reserve pages for conditions that need a prompt human response. A brief spike in CPU usage might be useful on a dashboard but not worth waking someone for. A disk that is projected to fill before the next shift, on the other hand, can justify a page even if users are not affected yet. If the recipient can wait until business hours, a ticket may be a better fit. Frequent notifications that require no action create alert fatigue and make urgent signals easier to miss.
In interviews
If asked to design alerts for an API, start with what users would notice. Then explain the metric, threshold, evaluation window, recipient, and first response. Cover low traffic and missing data separately: one failure out of two requests yields a 50% error rate, while a missing metric may indicate that telemetry has stopped rather than that the service is healthy.