Preserve distributed job context and expose grade 4 operational signals
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"graphTooltip": 1,
|
||||
"refresh": "10s",
|
||||
"schemaVersion": 41,
|
||||
"version": 1,
|
||||
"version": 2,
|
||||
"time": {
|
||||
"from": "now-30m",
|
||||
"to": "now"
|
||||
@@ -302,6 +302,268 @@
|
||||
"w": 12,
|
||||
"h": 10
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 16,
|
||||
"type": "timeseries",
|
||||
"title": "Durable queue depth (includes retry)",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 20,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "max(messenger_queue_depth)",
|
||||
"legendFormat": "{{job}} {{__name__}}"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 17,
|
||||
"type": "timeseries",
|
||||
"title": "Oldest durable job age",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 20,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "max(messenger_queue_oldest_age_seconds)",
|
||||
"legendFormat": "{{job}} {{__name__}}"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 18,
|
||||
"type": "timeseries",
|
||||
"title": "DB pool used / waiting / capacity",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 28,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (__name__,job) ({__name__=~\"messenger_db_pool_(used|waiting|capacity)\"})",
|
||||
"legendFormat": "{{job}} {{__name__}}"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 19,
|
||||
"type": "timeseries",
|
||||
"title": "Worker busy / capacity",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 28,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (__name__) ({__name__=~\"messenger_worker_(busy|capacity)\"})",
|
||||
"legendFormat": "{{job}} {{__name__}}"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 20,
|
||||
"type": "timeseries",
|
||||
"title": "Process CPU cores",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 36,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (job) (rate(process_cpu_time_seconds_total{job=~\"messenger-.*\"}[1m]))",
|
||||
"legendFormat": "{{job}} {{__name__}}"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 21,
|
||||
"type": "timeseries",
|
||||
"title": "Process resident memory",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 36,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "sum by (job) (process_memory_usage_bytes{job=~\"messenger-.*\"})",
|
||||
"legendFormat": "{{job}} {{__name__}}"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "bytes"
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 22,
|
||||
"type": "timeseries",
|
||||
"title": "Time to ready p50 / p95 / p99",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 44,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "histogram_quantile(0.5,sum by (le) (rate(messenger_job_time_to_ready_seconds_bucket[5m])))",
|
||||
"legendFormat": "0.5"
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"expr": "histogram_quantile(0.95,sum by (le) (rate(messenger_job_time_to_ready_seconds_bucket[5m])))",
|
||||
"legendFormat": "0.95"
|
||||
},
|
||||
{
|
||||
"refId": "C",
|
||||
"expr": "histogram_quantile(0.99,sum by (le) (rate(messenger_job_time_to_ready_seconds_bucket[5m])))",
|
||||
"legendFormat": "0.99"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 23,
|
||||
"type": "timeseries",
|
||||
"title": "Ready within 30s, SLO 95% / 1h",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 12,
|
||||
"y": 44,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "messenger:ready_under_30s:ratio1h",
|
||||
"legendFormat": "{{job}} {{__name__}}"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percentunit"
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 24,
|
||||
"type": "timeseries",
|
||||
"title": "API availability, SLO 99% / 1h",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"gridPos": {
|
||||
"x": 0,
|
||||
"y": 52,
|
||||
"w": 12,
|
||||
"h": 8
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"expr": "messenger:availability:ratio1h",
|
||||
"legendFormat": "{{job}} {{__name__}}"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percentunit"
|
||||
},
|
||||
"overrides": []
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
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
|
||||
@@ -0,0 +1,15 @@
|
||||
# Локальная диагностика
|
||||
|
||||
SLI availability = 1 − business HTTP 5xx / все business HTTP за 1 h, цель 99%; health исключены, 4xx остаются в знаменателе. SLI ready = доля завершённых jobs с time-to-ready <=30 s за 1 h, цель 95%. Незавершённые jobs не входят в histogram, поэтому возраст/depth контролируются отдельно. Учебные alerts реагируют раньше окна SLO: это пороговые предупреждения, не multi-window burn rates.
|
||||
|
||||
## MessengerHighErrorRate
|
||||
|
||||
Условие: 5xx/все >5% за 1 m непрерывно 15 s; вычисление каждые 5 s. В API dashboard проверить error ratio и p95. По request_id найти лог и trace. Длинный/ошибочный PostgreSQL client span указывает на зависимость; длинный server span без медленных client spans — на handler. Проверить used/waiting/capacity пула и ресурсы процесса. В своём стенде восстановить postgres, дождаться ready обеих API и успешных запросов. Alert должен исчезнуть после ухода ошибок из минутного окна.
|
||||
|
||||
## MessengerQueueLag
|
||||
|
||||
Условие: durable depth>0 и oldest age>15 s непрерывно 15 s. Проверить jobs outcomes, worker busy/capacity, CPU/RAM и наличие worker logs. Отсутствие worker signal при растущем backlog указывает на остановку процесса; retry с S3 ERROR spans — на хранилище. Проверить producer/consumer цепочку конкретного attachment. Восстановить только свой worker/зависимость; дождаться ready, depth=0, age=0 и отсутствия firing alert. Queue depth относится к PostgreSQL queued/processing, включая scheduled retry, а не только AMQP ready messages.
|
||||
|
||||
## Отказ telemetry backend
|
||||
|
||||
Readiness API не зависит от Collector/хранилищ. Сначала проверить бизнес-smoke. Collector: queue_size/capacity, send_failed и sent counters; Docker RAM против mem_limit. Retry ограничен 60 s, очереди ограничены; потеря диагностических данных при заполнении допустима, потеря сообщений — нет. Восстановить backend и проверить новый request trace/log и метрики. Не удалять volumes для восстановления.
|
||||
Reference in New Issue
Block a user