diff --git a/infra/prometheus/rules/alerts.yaml b/infra/prometheus/rules/alerts.yaml new file mode 100644 index 0000000..4c027c6 --- /dev/null +++ b/infra/prometheus/rules/alerts.yaml @@ -0,0 +1,44 @@ +groups: + - name: messenger-alerts + interval: 30s + rules: + - alert: MessengerHighErrorRate + expr: | + sum(rate(http_requests_total{http_status_class="5xx"}[5m])) + / + sum(rate(http_requests_total[5m])) + > 0.05 + for: 2m + labels: + severity: warning + annotations: + summary: "API error rate > 5% over 5m" + description: "5xx ratio exceeds SLO 5% for 2 minutes." + runbook: "infra/runbooks/high-error-rate.md" + + - alert: MessengerJobsBacklogGrowing + expr: | + sum(increase(jobs_processed_total{outcome="retry"}[10m])) + > + sum(increase(jobs_processed_total{outcome="success"}[10m])) + + 5 + for: 5m + labels: + severity: warning + annotations: + summary: "Retries outpace successes" + description: "Worker retry count exceeds successes for 5m." + runbook: "infra/runbooks/queue-lag.md" + + - alert: MessengerUploadLatencyHigh + expr: | + histogram_quantile(0.95, + sum by (le, http_route) + (rate(http_request_duration_seconds_bucket{http_route=~"/api/v1/chats/.*/attachments"}[5m])) + ) > 2 + for: 3m + labels: + severity: warning + annotations: + summary: "p95 upload latency > 2s" + runbook: "infra/runbooks/slow-upload.md" \ No newline at end of file