{ "uid": "messenger-lab6", "title": "Messenger lab6 — API, worker, очередь", "tags": [ "lab6", "messenger" ], "timezone": "browser", "schemaVersion": 39, "version": 1, "editable": false, "refresh": "10s", "time": { "from": "now-30m", "to": "now" }, "annotations": { "list": [] }, "templating": { "list": [] }, "panels": [ { "type": "row", "title": "API: RED (бизнес-запросы, health исключены)", "id": 1, "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 0 } }, { "type": "timeseries", "title": "RPS по маршруту и классу статуса", "id": 2, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "rate(http_server_request_duration_seconds_count[1m]); класс статуса из http_response_status_code", "gridPos": { "h": 8, "w": 8, "x": 0, "y": 1 }, "fieldConfig": { "defaults": { "unit": "reqps", "min": 0 }, "overrides": [] }, "targets": [ { "expr": "sum by (http_route, status_class) (label_replace(rate(http_server_request_duration_seconds_count{job=\"messenger-api\"}[1m]), \"status_class\", \"${1}xx\", \"http_response_status_code\", \"(\\\\d)..\"))", "legendFormat": "{{http_route}} {{status_class}}", "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "type": "timeseries", "title": "Доля 5xx (SLI ошибок)", "id": 3, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "numerator: 5xx; denominator: все бизнес-запросы. Порог алерта 5%", "gridPos": { "h": 8, "w": 8, "x": 8, "y": 1 }, "fieldConfig": { "defaults": { "unit": "percentunit", "min": 0, "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 0.05 } ] }, "custom": { "thresholdsStyle": { "mode": "line" } } }, "overrides": [] }, "targets": [ { "expr": "messenger:http_error_ratio:rate1m", "legendFormat": "5xx / все, окно 1m", "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "type": "timeseries", "title": "Латентность p50 / p95 / p99 (из histogram)", "id": 4, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "Квантили из buckets всех реплик (sum by le), не среднее p95 реплик", "gridPos": { "h": 8, "w": 8, "x": 16, "y": 1 }, "fieldConfig": { "defaults": { "unit": "s", "min": 0 }, "overrides": [] }, "targets": [ { "expr": "histogram_quantile(0.5, sum by (le) (rate(http_server_request_duration_seconds_bucket{job=\"messenger-api\"}[5m])))", "legendFormat": "p50", "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "expr": "histogram_quantile(0.95, sum by (le) (rate(http_server_request_duration_seconds_bucket{job=\"messenger-api\"}[5m])))", "legendFormat": "p95", "refId": "B", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "expr": "histogram_quantile(0.99, sum by (le) (rate(http_server_request_duration_seconds_bucket{job=\"messenger-api\"}[5m])))", "legendFormat": "p99", "refId": "C", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "type": "timeseries", "title": "p95 по маршруту", "id": 5, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "", "gridPos": { "h": 8, "w": 12, "x": 0, "y": 9 }, "fieldConfig": { "defaults": { "unit": "s", "min": 0 }, "overrides": [] }, "targets": [ { "expr": "histogram_quantile(0.95, sum by (le, http_route) (rate(http_server_request_duration_seconds_bucket{job=\"messenger-api\"}[5m])))", "legendFormat": "{{http_route}}", "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "type": "stat", "title": "SLO доступности, окно 1 ч (цель 99%)", "id": 6, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "1 - 5xx/все за 1h", "gridPos": { "h": 8, "w": 6, "x": 12, "y": 9 }, "fieldConfig": { "defaults": { "unit": "percentunit", "min": 0, "thresholds": { "mode": "absolute", "steps": [ { "color": "red", "value": null }, { "color": "green", "value": 0.99 } ] } }, "overrides": [] }, "targets": [ { "expr": "messenger:http_availability:ratio1h", "legendFormat": "availability 1h", "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "type": "stat", "title": "SLO задержки: доля < 0.5 с, 1 ч (цель 95%)", "id": 7, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "", "gridPos": { "h": 8, "w": 6, "x": 18, "y": 9 }, "fieldConfig": { "defaults": { "unit": "percentunit", "min": 0, "thresholds": { "mode": "absolute", "steps": [ { "color": "red", "value": null }, { "color": "green", "value": 0.95 } ] } }, "overrides": [] }, "targets": [ { "expr": "messenger:http_fast_ratio:ratio1h", "legendFormat": "fast 1h", "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "type": "row", "title": "Worker и очередь attachments.jobs", "id": 8, "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 17 } }, { "type": "timeseries", "title": "Задания по исходу", "id": 9, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "succeeded / retry / failed / noop / lease_lost / poison / error", "gridPos": { "h": 8, "w": 8, "x": 0, "y": 18 }, "fieldConfig": { "defaults": { "unit": "ops", "min": 0 }, "overrides": [] }, "targets": [ { "expr": "sum by (outcome) (rate(messenger_jobs_processed_total[1m]))", "legendFormat": "{{outcome}}", "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "type": "timeseries", "title": "Длительность задания p50 / p95 / p99", "id": 10, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "", "gridPos": { "h": 8, "w": 8, "x": 8, "y": 18 }, "fieldConfig": { "defaults": { "unit": "s", "min": 0 }, "overrides": [] }, "targets": [ { "expr": "histogram_quantile(0.5, sum by (le) (rate(messenger_job_duration_seconds_bucket[5m])))", "legendFormat": "p50", "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_job_duration_seconds_bucket[5m])))", "legendFormat": "p95", "refId": "B", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "expr": "histogram_quantile(0.99, sum by (le) (rate(messenger_job_duration_seconds_bucket[5m])))", "legendFormat": "p99", "refId": "C", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "type": "timeseries", "title": "Время до ready p50 / p95 (end-to-end)", "id": 11, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "От COMMIT задания (ответ 202) до COMMIT ready", "gridPos": { "h": 8, "w": 8, "x": 16, "y": 18 }, "fieldConfig": { "defaults": { "unit": "s", "min": 0 }, "overrides": [] }, "targets": [ { "expr": "histogram_quantile(0.5, sum by (le) (rate(messenger_attachment_time_to_ready_seconds_bucket[5m])))", "legendFormat": "p50", "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_attachment_time_to_ready_seconds_bucket[5m])))", "legendFormat": "p95", "refId": "B", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "type": "timeseries", "title": "Глубина очереди", "id": 12, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "Из PostgreSQL (публикуют API-реплики, max по репликам)", "gridPos": { "h": 8, "w": 8, "x": 0, "y": 26 }, "fieldConfig": { "defaults": { "unit": "short", "min": 0 }, "overrides": [] }, "targets": [ { "expr": "max by (state) (messenger_queue_depth{queue=\"attachments.jobs\"})", "legendFormat": "{{state}}", "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "expr": "max(messenger_outbox_pending{queue=\"attachments.jobs\"})", "legendFormat": "outbox (не опубликовано)", "refId": "B", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "type": "timeseries", "title": "Возраст старейшего задания", "id": 13, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "Порог алерта QueueLagGrowing: 60 с", "gridPos": { "h": 8, "w": 8, "x": 8, "y": 26 }, "fieldConfig": { "defaults": { "unit": "s", "min": 0, "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 60 } ] }, "custom": { "thresholdsStyle": { "mode": "line" } } }, "overrides": [] }, "targets": [ { "expr": "max(messenger_queue_oldest_age_seconds{queue=\"attachments.jobs\"})", "legendFormat": "oldest age", "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "type": "timeseries", "title": "Saturation worker (busy / capacity)", "id": 14, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "", "gridPos": { "h": 8, "w": 8, "x": 16, "y": 26 }, "fieldConfig": { "defaults": { "unit": "percentunit", "min": 0 }, "overrides": [ { "matcher": { "id": "byName", "options": "capacity (слотов)" }, "properties": [ { "id": "unit", "value": "short" }, { "id": "custom.axisPlacement", "value": "right" } ] } ] }, "targets": [ { "expr": "sum(messenger_worker_busy) / sum(messenger_worker_capacity)", "legendFormat": "busy/capacity", "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "expr": "sum(messenger_worker_capacity)", "legendFormat": "capacity (слотов)", "refId": "B", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "type": "row", "title": "Ресурсы: DB pool, CPU, RAM", "id": 15, "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 34 } }, { "type": "timeseries", "title": "DB pool: занято / ожидают / максимум", "id": 16, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "", "gridPos": { "h": 8, "w": 8, "x": 0, "y": 35 }, "fieldConfig": { "defaults": { "unit": "short", "min": 0 }, "overrides": [] }, "targets": [ { "expr": "sum by (job, instance) (messenger_db_pool_connections{state=\"used\"})", "legendFormat": "{{job}} {{instance}} used", "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "expr": "sum by (job, instance) (messenger_db_pool_waiting)", "legendFormat": "{{job}} {{instance}} waiting", "refId": "B", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "expr": "max by (job) (messenger_db_pool_max)", "legendFormat": "{{job}} max", "refId": "C", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "type": "timeseries", "title": "CPU процесса (ядра)", "id": 17, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "", "gridPos": { "h": 8, "w": 8, "x": 8, "y": 35 }, "fieldConfig": { "defaults": { "unit": "short", "min": 0 }, "overrides": [] }, "targets": [ { "expr": "rate(process_cpu_time_seconds_total{job=~\"messenger-.+\"}[1m])", "legendFormat": "{{job}} {{instance}}", "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "type": "timeseries", "title": "RSS процесса", "id": 18, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "", "gridPos": { "h": 8, "w": 8, "x": 16, "y": 35 }, "fieldConfig": { "defaults": { "unit": "bytes", "min": 0 }, "overrides": [] }, "targets": [ { "expr": "process_memory_rss_bytes{job=~\"messenger-.+\"}", "legendFormat": "{{job}} {{instance}}", "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "type": "row", "title": "Конвейер телеметрии (Collector)", "id": 19, "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 43 } }, { "type": "timeseries", "title": "Collector: принято / отправлено / потеряно (spans)", "id": 20, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "", "gridPos": { "h": 8, "w": 12, "x": 0, "y": 44 }, "fieldConfig": { "defaults": { "unit": "short", "min": 0 }, "overrides": [] }, "targets": [ { "expr": "sum(rate(otelcol_receiver_accepted_spans[1m]))", "legendFormat": "accepted", "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "expr": "sum(rate(otelcol_exporter_sent_spans[1m]))", "legendFormat": "sent", "refId": "B", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "expr": "(sum(rate(otelcol_exporter_send_failed_spans[1m])) or vector(0)) + (sum(rate(otelcol_exporter_enqueue_failed_spans[1m])) or vector(0))", "legendFormat": "lost", "refId": "C", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "expr": "sum(rate(otelcol_receiver_refused_spans[1m]))", "legendFormat": "refused (memory_limiter)", "refId": "D", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "type": "timeseries", "title": "Collector: логи и очередь экспорта", "id": 21, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "", "gridPos": { "h": 8, "w": 12, "x": 12, "y": 44 }, "fieldConfig": { "defaults": { "unit": "short", "min": 0 }, "overrides": [] }, "targets": [ { "expr": "sum(rate(otelcol_exporter_sent_log_records[1m]))", "legendFormat": "logs sent", "refId": "A", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "expr": "(sum(rate(otelcol_exporter_send_failed_log_records[1m])) or vector(0)) + (sum(rate(otelcol_exporter_enqueue_failed_log_records[1m])) or vector(0))", "legendFormat": "logs lost", "refId": "B", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "expr": "max by (exporter) (otelcol_exporter_queue_size)", "legendFormat": "queue {{exporter}}", "refId": "C", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "type": "row", "title": "Логи и трассы", "id": 22, "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 52 } }, { "type": "logs", "title": "Логи WARNING/ERROR API и worker", "id": 23, "datasource": { "type": "loki", "uid": "loki" }, "description": "", "gridPos": { "h": 10, "w": 12, "x": 0, "y": 53 }, "fieldConfig": { "defaults": { "unit": "short", "min": 0 }, "overrides": [] }, "targets": [ { "expr": "{service_name=~\"messenger-.+\"} | severity_text=~\"WARNING|ERROR|CRITICAL\"", "queryType": "range", "refId": "A", "datasource": { "type": "loki", "uid": "loki" } } ], "options": { "showTime": true, "wrapLogMessage": true, "enableLogDetails": true, "sortOrder": "Descending" } }, { "type": "table", "title": "Трассы обработки заданий (consumer spans)", "id": 24, "datasource": { "type": "tempo", "uid": "tempo" }, "description": "", "gridPos": { "h": 10, "w": 12, "x": 12, "y": 53 }, "fieldConfig": { "defaults": { "unit": "short", "min": 0 }, "overrides": [] }, "targets": [ { "query": "{resource.service.name=\"messenger-worker\" && kind=consumer}", "queryType": "traceql", "limit": 20, "tableType": "traces", "refId": "A", "datasource": { "type": "tempo", "uid": "tempo" } } ] } ] }