{ "uid": "messenger-lab6", "title": "Messenger · наблюдаемость", "tags": [ "lab6", "messenger" ], "schemaVersion": 41, "timezone": "browser", "version": 1, "refresh": "5s", "time": { "from": "now-15m", "to": "now" }, "panels": [ { "id": 1, "type": "timeseries", "title": "HTTP — запросы в секунду", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 0, "y": 0, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "reqps" }, "overrides": [] }, "targets": [ { "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "sum by (method, route) (rate(messenger_http_requests_total[1m]))", "legendFormat": "{{method}} {{route}}" } ] }, { "id": 2, "type": "timeseries", "title": "HTTP — длительность", "description": "Перцентили из суммарных histogram buckets всех API-реплик за 2 минуты.", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 12, "y": 0, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "s" }, "overrides": [] }, "targets": [ { "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "histogram_quantile(0.5, sum by (le) (rate(messenger_http_duration_seconds_bucket[2m])))", "legendFormat": "p50" }, { "refId": "B", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_http_duration_seconds_bucket[2m])))", "legendFormat": "p95" }, { "refId": "C", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "histogram_quantile(0.99, sum by (le) (rate(messenger_http_duration_seconds_bucket[2m])))", "legendFormat": "p99" } ] }, { "id": 3, "type": "timeseries", "title": "HTTP — доля 5xx", "description": "Только /api/v1. Health и Swagger исключены. 4xx входят в знаменатель.", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 0, "y": 8, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "percentunit" }, "overrides": [] }, "targets": [ { "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "messenger:http_error_ratio:30s", "legendFormat": "5xx / все запросы" } ] }, { "id": 4, "type": "timeseries", "title": "SLO доступности API за 15 минут", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 12, "y": 8, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "percentunit" }, "overrides": [] }, "targets": [ { "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "messenger:http_availability:15m", "legendFormat": "SLI" }, { "refId": "B", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "vector(0.99)", "legendFormat": "SLO 99%" } ] }, { "id": 5, "type": "timeseries", "title": "Worker — исходы обработки", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 0, "y": 16, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "ops" }, "overrides": [] }, "targets": [ { "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "sum by (outcome) (rate(messenger_jobs_total[1m]))", "legendFormat": "{{outcome}}" } ] }, { "id": 6, "type": "timeseries", "title": "Worker — время обработки", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 12, "y": 16, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "s" }, "overrides": [] }, "targets": [ { "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "histogram_quantile(0.5, sum by (le) (rate(messenger_job_duration_seconds_bucket[2m])))", "legendFormat": "p50" }, { "refId": "B", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_job_duration_seconds_bucket[2m])))", "legendFormat": "p95" }, { "refId": "C", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "histogram_quantile(0.99, sum by (le) (rate(messenger_job_duration_seconds_bucket[2m])))", "legendFormat": "p99" } ] }, { "id": 7, "type": "timeseries", "title": "Очередь — ожидающие задания", "description": "Устойчивый backlog в PostgreSQL включает задачи до publish и после publish, пока worker их не захватил.", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 0, "y": 24, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "short" }, "overrides": [] }, "targets": [ { "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "max(messenger_queue_depth)", "legendFormat": "queued" }, { "refId": "B", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "max(messenger_outbox_pending)", "legendFormat": "не отправлено в RabbitMQ" } ] }, { "id": 8, "type": "timeseries", "title": "Очередь — возраст старейшей job", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 12, "y": 24, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "s" }, "overrides": [] }, "targets": [ { "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "max by (queue) (messenger_queue_oldest_age_seconds)", "legendFormat": "{{queue}}" } ] }, { "id": 9, "type": "timeseries", "title": "Время от 202 до ready", "description": "От создания job в транзакции принятия до COMMIT готового вложения.", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 0, "y": 32, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "s" }, "overrides": [] }, "targets": [ { "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "histogram_quantile(0.5, sum by (le) (rate(messenger_attachment_ready_duration_seconds_bucket[2m])))", "legendFormat": "p50" }, { "refId": "B", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_attachment_ready_duration_seconds_bucket[2m])))", "legendFormat": "p95" }, { "refId": "C", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "histogram_quantile(0.99, sum by (le) (rate(messenger_attachment_ready_duration_seconds_bucket[2m])))", "legendFormat": "p99" } ] }, { "id": 10, "type": "timeseries", "title": "Worker — занятые слоты", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 12, "y": 32, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "percentunit" }, "overrides": [] }, "targets": [ { "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "sum(messenger_worker_busy) / sum(messenger_worker_capacity)", "legendFormat": "busy / capacity" } ] }, { "id": 11, "type": "timeseries", "title": "PostgreSQL — пул соединений", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 0, "y": 40, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "short" }, "overrides": [] }, "targets": [ { "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "sum by (service_name, state) (messenger_db_pool{state=~\"used|waiting|capacity\"})", "legendFormat": "{{service_name}} {{state}}" } ] }, { "id": 12, "type": "timeseries", "title": "CPU — ядра", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 12, "y": 40, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "cores" }, "overrides": [] }, "targets": [ { "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "sum by (service_name) (rate(messenger_process_cpu_seconds_total[1m]))", "legendFormat": "процесс {{service_name}}" }, { "refId": "B", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "sum by (service_name) (rate(messenger_container_cpu_seconds_total[1m]))", "legendFormat": "контейнер {{service_name}}" } ] }, { "id": 13, "type": "timeseries", "title": "RAM — процесс и контейнер", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 0, "y": 48, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "bytes" }, "overrides": [] }, "targets": [ { "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "sum by (service_name) (messenger_process_memory_bytes)", "legendFormat": "RSS {{service_name}}" }, { "refId": "B", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "sum by (service_name) (messenger_container_memory_bytes)", "legendFormat": "cgroup {{service_name}}" } ] }, { "id": 14, "type": "timeseries", "title": "Алерты", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 12, "y": 48, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "short" }, "overrides": [] }, "targets": [ { "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "ALERTS", "legendFormat": "{{alertname}} {{alertstate}}" } ] }, { "id": 15, "type": "timeseries", "title": "Collector — потери записей", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 0, "y": 56, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "short" }, "overrides": [] }, "targets": [ { "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "sum(increase(otelcol_exporter_send_failed_log_records_total[1m])) + sum(increase(otelcol_exporter_enqueue_failed_log_records_total[1m]))", "legendFormat": "логи {{exporter}}" }, { "refId": "B", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "sum(increase(otelcol_exporter_send_failed_spans_total[1m])) + sum(increase(otelcol_exporter_enqueue_failed_spans_total[1m]))", "legendFormat": "спаны {{exporter}}" } ] }, { "id": 16, "type": "timeseries", "title": "Collector — память", "description": "RSS процесса Collector. Лимит контейнера 256 MiB.", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 12, "y": 56, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "bytes" }, "overrides": [] }, "targets": [ { "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" }, "expr": "otelcol_process_memory_rss_bytes", "legendFormat": "RSS" } ] }, { "id": 17, "type": "logs", "title": "API, dispatcher и worker", "datasource": { "type": "loki", "uid": "loki" }, "gridPos": { "x": 0, "y": 64, "w": 24, "h": 12 }, "targets": [ { "refId": "A", "datasource": { "type": "loki", "uid": "loki" }, "expr": "{service_name=~\"messenger-api|messenger-worker|messenger-dispatcher\"} | event=~\"http.response|job.processed|job.processing_error|postgres.unavailable\"" } ], "options": { "showTime": true, "showLabels": true, "enableLogDetails": true } } ] }