Reading — step 1 of 5
Read
~1 min readOperations
Alerting on Logs
Alerts fire when a query result crosses a threshold:
- "More than 100 errors per minute"
- "No INFO logs from service:api for 5 minutes" (means it's down)
- "An ERROR matching 'OutOfMemory' anywhere"
Alert manager pattern:
- name: high-error-rate
expr: sum(rate({level="error"}[5m])) > 100
for: 5m # must be true for 5 min before firing
annotations:
summary: "Error rate spike"
Evaluation:
- Every 30s, run the expression.
- If true, start a "pending" timer.
- If still true after
forduration, transition to "firing" → notify. - If becomes false, reset.
Notifications:
- Slack / PagerDuty / email.
- De-dupe: same alert + same labels → group, send once.
- Inhibition: if "host_down" fires, suppress "high_error_rate" for that host.
Watching for ABSENCE of logs is critical — a service that stops logging is often a service that crashed but didn't restart cleanly.
Real systems: Prometheus AlertManager (used with Loki/Cortex), Datadog Monitors.
Implementation:
python
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…