Files
mtusi2026lab2/infra/prometheus/rules/messenger.alerts.yml
T

31 lines
1.7 KiB
YAML

groups:
- name: messenger-slo
interval: 5s
rules:
- record: messenger:http_errors:ratio_rate1m
expr: |
(sum(rate(http_server_request_duration_seconds_count{job="messenger-api",http_route!~"/health/.*",http_response_status_code=~"5.."}[1m])) or vector(0))
/ clamp_min(sum(rate(http_server_request_duration_seconds_count{job="messenger-api",http_route!~"/health/.*"}[1m])), 0.001)
- record: messenger:availability:ratio1h
expr: 1 - messenger:http_errors:ratio_rate1h
- record: messenger:ready_under_30s:ratio1h
expr: sum(increase(messenger_job_time_to_ready_seconds_bucket{le="30"}[1h])) / clamp_min(sum(increase(messenger_job_time_to_ready_seconds_count[1h])), 1)
- alert: MessengerHighErrorRate
expr: messenger:http_errors:ratio_rate1m > 0.05
for: 15s
labels:
severity: warning
annotations:
summary: More than 5% business HTTP 5xx over 1 minute
description: Availability target is 99% over 1 hour; health and client 4xx are excluded from failures.
runbook: infra/prometheus/runbooks.md#messengerhigherrorrate
- alert: MessengerQueueLag
expr: max(messenger_queue_oldest_age_seconds{queue_name="attachments.process"}) > 15 and max(messenger_queue_depth{queue_name="attachments.process"}) > 0
for: 15s
labels:
severity: warning
annotations:
summary: Durable attachment backlog has waited more than 15 seconds
description: Target is 95% ready within 30 seconds over 1 hour; depth includes retry and leased work.
runbook: infra/prometheus/runbooks.md#messengerqueuelag