Section 6 · Create an alert with code

Vague rule names, unsafe no-data handling, missing pending periods, and counter queries without a range function.

Estimated time: 1 min

Common mistakes to avoid

These issues appear frequently in production alerting setups:

IssueMistakeFix
Hard to identify the problem from the notificationVague alert namesUse names that describe what and where
Outages go unnoticed when data stops arrivingNo-data set to NormalUse Keep Last State or Alerting for critical rules
Alerts fire on temporary spikesMissing pending periodSet a pending period appropriate for your data
Incorrect values from counter metricsSkipping a range function on a counter like quickpizza_server_http_requests_totalAdd Increase (or Rate) over a time window before aggregating
The alert fires on data that hasn’t fully arrived yetChecking incomplete dataAdjust the query time range to exclude the most recent, incomplete data
The alert has nothing to evaluateSkipping the query previewRun Preview and confirm one or more time series appear before saving