Lab 6: track - 1

This commit is contained in:
2026-11-23 14:54:48 +03:00
parent 470d9d6f1e
commit a271ddd156
39 changed files with 3141 additions and 15 deletions
+24
View File
@@ -0,0 +1,24 @@
# Runbooks для инцидентов и алертов
## 1. High API 5xx Error Ratio (`messenger-high-5xx`)
- **Условие:** доля 5xx по бизнес-эндпоинтам (исключая `/health/*`) превышает 5% за 1 минуту (`for: 15s`).
- **Шаги диагностики:**
1. Открыть Grafana → Dashboard `MTUSI Messenger — Lab 6 Observability` → панель `API 5xx Error Ratio` и `DB Pool Saturation`.
2. Проверить в Tempo (Explore → `{ resource.service.name = "messenger-api" && status = error }`) какой дочерний span упал или замедлился (`db.query`, `db.pool.connect`, `s3.put_staging`, `broker.ping`).
3. Перейти по `trace_id` в Loki (`{service_name="messenger-api"} | trace_id="..."`) и проверить `error.code` / `request_id`.
- **Действия:** проверить состояние PostgreSQL / RustFS / Redis, при блокировках БД проверить `pg_stat_activity`.
## 2. Growing Queue Lag (`messenger-queue-lag`)
- **Условие:** возраст старейшей незавершённой задачи `worker_oldest_job_age_seconds > 15s` (`for: 15s`).
- **Шаги диагностики:**
1. Открыть панель `Queue Depth & Oldest Job Age` и `Worker Concurrency Saturation`.
2. Если `worker_threads{state="busy"} == 0` при растущей очереди — процесс `worker` остановлен или потерял связь с брокером.
3. Если `busy == capacity` и растёт `worker_job_duration_seconds` — нехватка CPU/конкурентности или тормозит S3/DB.
4. Проверить логи `{service_name="messenger-worker"}` на события `worker.retry` и `worker.failed`.
- **Действия:** запустить/восстановить `worker`, проверить `attachment-jobs-dlq`, при необходимости увеличить `WORKER_CONCURRENCY`.
## 3. API p95 Latency SLO Breach (`messenger-latency-slo`)
- **Условие:** `p95` по бизнес-эндпоинтам > 0.5 с за 1 минуту (`for: 30s`).
- **Шаги диагностики:**
1. В Tempo найти медленные трассы (`duration > 500ms`).
2. Отличить медленную БД (время внутри `db.query` / `db.pool.connect`) от медленного кода API (разрыв между длительностью корневого server span и дочерними зависимостями).
+100
View File
@@ -0,0 +1,100 @@
extensions:
health_check:
endpoint: 0.0.0.0:13133
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
processors:
memory_limiter:
check_interval: 1s
limit_mib: 180
spike_limit_mib: 40
attributes/redact:
actions:
- key: http.request.header.authorization
action: delete
- key: db.statement
action: delete
tail_sampling:
decision_wait: 2s
num_traces: 5000
expected_new_traces_per_sec: 100
policies:
- name: errors-policy
type: status_code
status_code:
status_codes: [ERROR]
- name: slow-traces-policy
type: latency
latency:
threshold_ms: 100
- name: fast-sample-policy
type: probabilistic
probabilistic:
sampling_percentage: 10
batch:
send_batch_size: 256
timeout: 1s
exporters:
prometheus:
endpoint: 0.0.0.0:8889
resource_to_telemetry_conversion:
enabled: true
metric_expiration: 5m
otlphttp/loki:
endpoint: http://loki:3100/otlp
tls:
insecure: true
retry_on_failure:
enabled: true
initial_interval: 1s
max_interval: 5s
max_elapsed_time: 15s
sending_queue:
enabled: true
num_consumers: 2
queue_size: 200
otlp/tempo:
endpoint: tempo:4317
tls:
insecure: true
retry_on_failure:
enabled: true
initial_interval: 1s
max_interval: 5s
max_elapsed_time: 15s
sending_queue:
enabled: true
num_consumers: 2
queue_size: 200
service:
extensions: [health_check]
telemetry:
metrics:
readers:
- pull:
exporter:
prometheus:
host: 0.0.0.0
port: 8888
pipelines:
metrics:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [prometheus]
logs:
receivers: [otlp]
processors: [memory_limiter, attributes/redact, batch]
exporters: [otlphttp/loki]
traces:
receivers: [otlp]
processors: [memory_limiter, attributes/redact, tail_sampling, batch]
exporters: [otlp/tempo]
+83
View File
@@ -0,0 +1,83 @@
extensions:
health_check:
endpoint: 0.0.0.0:13133
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
processors:
memory_limiter:
check_interval: 1s
limit_mib: 180
spike_limit_mib: 40
attributes/redact:
actions:
- key: http.request.header.authorization
action: delete
- key: db.statement
action: delete
batch:
send_batch_size: 256
timeout: 1s
exporters:
prometheus:
endpoint: 0.0.0.0:8889
resource_to_telemetry_conversion:
enabled: true
metric_expiration: 5m
otlphttp/loki:
endpoint: http://loki:3100/otlp
tls:
insecure: true
retry_on_failure:
enabled: true
initial_interval: 1s
max_interval: 5s
max_elapsed_time: 15s
sending_queue:
enabled: true
num_consumers: 2
queue_size: 200
otlp/tempo:
endpoint: tempo:4317
tls:
insecure: true
retry_on_failure:
enabled: true
initial_interval: 1s
max_interval: 5s
max_elapsed_time: 15s
sending_queue:
enabled: true
num_consumers: 2
queue_size: 200
service:
extensions: [health_check]
telemetry:
metrics:
readers:
- pull:
exporter:
prometheus:
host: 0.0.0.0
port: 8888
pipelines:
metrics:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [prometheus]
logs:
receivers: [otlp]
processors: [memory_limiter, attributes/redact, batch]
exporters: [otlphttp/loki]
traces:
receivers: [otlp]
processors: [memory_limiter, attributes/redact, batch]
exporters: [otlp/tempo]