{ "uid": "messenger-overview", "title": "Messenger — обзор (lab6)", "tags": [ "messenger", "lab6" ], "timezone": "browser", "schemaVersion": 39, "version": 1, "editable": false, "graphTooltip": 1, "refresh": "10s", "time": { "from": "now-30m", "to": "now" }, "description": "RED API, jobs, очередь, saturation, SLO/алерты, конвейер telemetry, логи и трассы. Источник — Git (infra/grafana/dashboards).", "links": [], "annotations": { "list": [ { "builtIn": 1, "datasource": { "type": "grafana", "uid": "-- Grafana --" }, "enable": true, "hide": true, "iconColor": "rgba(0, 211, 255, 1)", "name": "Annotations & Alerts", "type": "dashboard" } ] }, "templating": { "list": [] }, "panels": [ { "type": "row", "title": "SLO и алерты (окна учебного стенда; обоснование — REPORT.md)", "id": 1, "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 0 }, "panels": [] }, { "type": "stat", "title": "Доступность API, 1 ч (SLO 99.5%)", "id": 2, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "SLI: доля НЕ-5xx среди бизнес-запросов (без /health, /internal) за 1 ч. 4xx — ошибки клиента, в бюджет не входят. Единицы: доля (%).", "gridPos": { "h": 4, "w": 5, "x": 0, "y": 1 }, "fieldConfig": { "defaults": { "unit": "percentunit", "thresholds": { "mode": "absolute", "steps": [ { "color": "red", "value": null }, { "color": "orange", "value": 0.99 }, { "color": "green", "value": 0.995 } ] }, "decimals": 3 }, "overrides": [] }, "options": { "reduceOptions": { "calcs": [ "lastNotNull" ] }, "colorMode": "value", "graphMode": "area" }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "1 - (sum(increase(http_server_request_duration_seconds_count{service_name=\"messenger-api\",http_route!~\"/health/.*|/internal/.*\",http_response_status_class=\"5xx\"}[1h])) or vector(0)) / sum(increase(http_server_request_duration_seconds_count{service_name=\"messenger-api\",http_route!~\"/health/.*|/internal/.*\"}[1h]))", "instant": false, "range": true } ] }, { "type": "stat", "title": "Быстрые запросы ≤250 мс, 5 мин (SLO 95%)", "id": 3, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "SLI задержки: доля бизнес-запросов (кроме upload) с длительностью ≤ 0.25 с по bucket le=0.25 histogram. Единицы: доля.", "gridPos": { "h": 4, "w": 5, "x": 5, "y": 1 }, "fieldConfig": { "defaults": { "unit": "percentunit", "thresholds": { "mode": "absolute", "steps": [ { "color": "red", "value": null }, { "color": "orange", "value": 0.9 }, { "color": "green", "value": 0.95 } ] }, "decimals": 3 }, "overrides": [] }, "options": { "reduceOptions": { "calcs": [ "lastNotNull" ] }, "colorMode": "value", "graphMode": "area" }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "sli:api_fast_ratio:rate5m", "instant": false, "range": true } ] }, { "type": "stat", "title": "Ready ≤10 с, 15 мин (SLO 95%)", "id": 4, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "SLI time-to-ready: доля вложений, ставших ready не позже 10 с после durable acceptance (202). Единицы: доля.", "gridPos": { "h": 4, "w": 5, "x": 10, "y": 1 }, "fieldConfig": { "defaults": { "unit": "percentunit", "thresholds": { "mode": "absolute", "steps": [ { "color": "red", "value": null }, { "color": "orange", "value": 0.9 }, { "color": "green", "value": 0.95 } ] }, "decimals": 3 }, "overrides": [] }, "options": { "reduceOptions": { "calcs": [ "lastNotNull" ] }, "colorMode": "value", "graphMode": "area" }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "sli:time_to_ready_fast_ratio:rate15m", "instant": false, "range": true } ] }, { "type": "table", "title": "Алерты в состоянии firing/pending (Prometheus)", "id": 5, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "ALERTS — состояние правил Prometheus (infra/prometheus/rules/messenger.yml). Runbook: docs/runbooks.md.", "gridPos": { "h": 8, "w": 9, "x": 15, "y": 1 }, "fieldConfig": { "defaults": {}, "overrides": [] }, "options": { "showHeader": true }, "transformations": [ { "id": "labelsToFields", "options": { "mode": "columns" } }, { "id": "organize", "options": { "excludeByName": { "Time": true, "Value": true, "__name__": true } } } ], "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "ALERTS{alertstate=~\"firing|pending\"}", "instant": true, "format": "table" } ] }, { "type": "stat", "title": "Доля 5xx, 1 мин", "id": 6, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "Числитель: 5xx бизнес-запросов; знаменатель: все бизнес-запросы (без health). Алерт ApiHighErrorRate: > 5% 30 с.", "gridPos": { "h": 4, "w": 5, "x": 0, "y": 5 }, "fieldConfig": { "defaults": { "unit": "percentunit", "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 0.05 } ] }, "decimals": 2 }, "overrides": [] }, "options": { "reduceOptions": { "calcs": [ "lastNotNull" ] }, "colorMode": "value", "graphMode": "area" }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "sli:api_error_ratio:rate1m", "instant": false, "range": true } ] }, { "type": "stat", "title": "Queue lag", "id": 7, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "Сколько ждёт самое старое задание, уже доступное worker (без ожидания backoff). Алерт JobQueueLagGrowing: > 30 с.", "gridPos": { "h": 4, "w": 5, "x": 5, "y": 5 }, "fieldConfig": { "defaults": { "unit": "s", "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "orange", "value": 10 }, { "color": "red", "value": 30 } ] } }, "overrides": [] }, "options": { "reduceOptions": { "calcs": [ "lastNotNull" ] }, "colorMode": "value", "graphMode": "area" }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "sli:queue_lag_seconds:max", "instant": false, "range": true } ] }, { "type": "stat", "title": "Worker: занято / слотов", "id": 8, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "Saturation worker: занятые слоты обработки / WORKER_CONCURRENCY × реплики (метрики за последние 30 с).", "gridPos": { "h": 4, "w": 5, "x": 10, "y": 5 }, "fieldConfig": { "defaults": { "unit": "percentunit", "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "orange", "value": 0.8 }, { "color": "red", "value": 1 } ] } }, "overrides": [] }, "options": { "reduceOptions": { "calcs": [ "lastNotNull" ] }, "colorMode": "value", "graphMode": "area" }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "sum(last_over_time(messenger_worker_busy[30s])) / sum(last_over_time(messenger_worker_capacity[30s]))", "instant": false, "range": true } ] }, { "type": "row", "title": "API — RED (метрики SDK по ВСЕМ запросам; sampling трасс на них не влияет)", "id": 9, "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 9 }, "panels": [] }, { "type": "timeseries", "title": "RPS по маршруту", "id": 10, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "Счётчик = _count histogram http.server.request.duration. Маршрут — шаблон (/api/v1/chats/{chat_id}/messages), не URL. Единицы: запросов/с.", "gridPos": { "h": 8, "w": 8, "x": 0, "y": 10 }, "fieldConfig": { "defaults": { "unit": "reqps", "custom": { "lineWidth": 1, "fillOpacity": 10, "stacking": { "mode": "normal" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "sum by (http_route) (rate(http_server_request_duration_seconds_count{service_name=\"messenger-api\",http_route!~\"/health/.*|/internal/.*\"}[$__rate_interval]))", "legendFormat": "{{http_route}}", "range": true } ] }, { "type": "timeseries", "title": "Ответы по классу статуса", "id": 11, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "2xx/4xx/5xx бизнес-запросов. 4xx (неверный пароль, 404) — не отказ сервиса. Единицы: запросов/с.", "gridPos": { "h": 8, "w": 8, "x": 8, "y": 10 }, "fieldConfig": { "defaults": { "unit": "reqps", "custom": { "lineWidth": 1, "fillOpacity": 10, "stacking": { "mode": "normal" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "sum by (http_response_status_class) (rate(http_server_request_duration_seconds_count{service_name=\"messenger-api\",http_route!~\"/health/.*|/internal/.*\"}[$__rate_interval]))", "legendFormat": "{{http_response_status_class}}", "range": true } ] }, { "type": "timeseries", "title": "Латентность API p50 / p95 / p99", "id": 12, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "Перцентили из buckets histogram, сложенных по ВСЕМ репликам (sum by le), а не среднее p95 реплик. Единицы: секунды.", "gridPos": { "h": 8, "w": 8, "x": 16, "y": 10 }, "fieldConfig": { "defaults": { "unit": "s", "custom": { "lineWidth": 1, "fillOpacity": 10, "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "histogram_quantile(0.5, sum by (le) (rate(http_server_request_duration_seconds_bucket{service_name=\"messenger-api\",http_route!~\"/health/.*|/internal/.*\"}[$__rate_interval])))", "legendFormat": "p50", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "B", "expr": "histogram_quantile(0.95, sum by (le) (rate(http_server_request_duration_seconds_bucket{service_name=\"messenger-api\",http_route!~\"/health/.*|/internal/.*\"}[$__rate_interval])))", "legendFormat": "p95", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "C", "expr": "histogram_quantile(0.99, sum by (le) (rate(http_server_request_duration_seconds_bucket{service_name=\"messenger-api\",http_route!~\"/health/.*|/internal/.*\"}[$__rate_interval])))", "legendFormat": "p99", "range": true } ] }, { "type": "timeseries", "title": "p95 по маршруту", "id": 13, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "Какой маршрут медленный. Upload включает передачу файла клиентом — его задержка выше по природе.", "gridPos": { "h": 8, "w": 8, "x": 0, "y": 18 }, "fieldConfig": { "defaults": { "unit": "s", "custom": { "lineWidth": 1, "fillOpacity": 10, "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "histogram_quantile(0.95, sum by (le, http_route) (rate(http_server_request_duration_seconds_bucket{service_name=\"messenger-api\",http_route!~\"/health/.*|/internal/.*\"}[$__rate_interval])))", "legendFormat": "{{http_route}}", "range": true } ] }, { "type": "timeseries", "title": "PostgreSQL: p95 по операции (все сервисы)", "id": 14, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "db.client.operation.duration — время execute в PostgreSQL. Растёт вместе с HTTP p95 → медленная БД; HTTP растёт, а это нет → обработчик/CPU API.", "gridPos": { "h": 8, "w": 8, "x": 8, "y": 18 }, "fieldConfig": { "defaults": { "unit": "s", "custom": { "lineWidth": 1, "fillOpacity": 10, "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "histogram_quantile(0.95, sum by (le, db_operation_name) (rate(db_client_operation_duration_seconds_bucket{}[$__rate_interval])))", "legendFormat": "{{db_operation_name}}", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "B", "expr": "histogram_quantile(0.95, sum by (le) (rate(db_client_operation_duration_seconds_bucket{}[$__rate_interval])))", "legendFormat": "все операции", "range": true } ] }, { "type": "timeseries", "title": "Запросы в обработке (saturation API)", "id": 15, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "http.server.active_requests по реплике (включая health). Единицы: запросов одновременно.", "gridPos": { "h": 8, "w": 8, "x": 16, "y": 18 }, "fieldConfig": { "defaults": { "unit": "short", "custom": { "lineWidth": 1, "fillOpacity": 10, "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "sum by (service_instance_id) (last_over_time(http_server_active_requests{service_name=\"messenger-api\"}[30s]))", "legendFormat": "{{service_instance_id}}", "range": true } ] }, { "type": "row", "title": "Фоновая обработка — jobs, time to ready", "id": 16, "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 26 }, "panels": [] }, { "type": "timeseries", "title": "Jobs по исходу", "id": 17, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "messenger.jobs.processed: ready/retry/failed — попытки обработки; duplicate/stale/nak — повторные/ранние доставки без работы. Единицы: сообщений/с.", "gridPos": { "h": 8, "w": 8, "x": 0, "y": 27 }, "fieldConfig": { "defaults": { "unit": "ops", "custom": { "lineWidth": 1, "fillOpacity": 10, "stacking": { "mode": "normal" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "sum by (outcome) (rate(messenger_jobs_processed_total[$__rate_interval]))", "legendFormat": "{{outcome}}", "range": true } ] }, { "type": "timeseries", "title": "Длительность попытки p50 / p95 / p99", "id": 18, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "messenger.job.duration: от захвата задания до COMMIT результата/ошибки. Единицы: секунды.", "gridPos": { "h": 8, "w": 8, "x": 8, "y": 27 }, "fieldConfig": { "defaults": { "unit": "s", "custom": { "lineWidth": 1, "fillOpacity": 10, "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "histogram_quantile(0.5, sum by (le) (rate(messenger_job_duration_seconds_bucket{outcome=\"ready\"}[$__rate_interval])))", "legendFormat": "p50 ready", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "B", "expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_job_duration_seconds_bucket{outcome=\"ready\"}[$__rate_interval])))", "legendFormat": "p95 ready", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "C", "expr": "histogram_quantile(0.99, sum by (le) (rate(messenger_job_duration_seconds_bucket{outcome=\"ready\"}[$__rate_interval])))", "legendFormat": "p99 ready", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "D", "expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_job_duration_seconds_bucket{outcome!=\"ready\"}[$__rate_interval])))", "legendFormat": "p95 ошибки/повторы", "range": true } ] }, { "type": "timeseries", "title": "Time to ready p50 / p95 / p99 и ожидание в очереди", "id": 19, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "time_to_ready: от durable acceptance (202) до публикации ready (histogram). queue_wait: от доступности попытки до захвата worker. Backlog (глубина) — отдельная метрика ниже.", "gridPos": { "h": 8, "w": 8, "x": 16, "y": 27 }, "fieldConfig": { "defaults": { "unit": "s", "custom": { "lineWidth": 1, "fillOpacity": 10, "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "histogram_quantile(0.5, sum by (le) (rate(messenger_attachment_time_to_ready_seconds_bucket{}[$__rate_interval])))", "legendFormat": "ready p50", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "B", "expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_attachment_time_to_ready_seconds_bucket{}[$__rate_interval])))", "legendFormat": "ready p95", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "C", "expr": "histogram_quantile(0.99, sum by (le) (rate(messenger_attachment_time_to_ready_seconds_bucket{}[$__rate_interval])))", "legendFormat": "ready p99", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "D", "expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_job_queue_wait_seconds_bucket{}[$__rate_interval])))", "legendFormat": "queue wait p95", "range": true } ] }, { "type": "row", "title": "Очередь заданий (outbox → NATS JetStream → worker)", "id": 20, "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 35 }, "panels": [] }, { "type": "timeseries", "title": "Глубина очереди по состоянию", "id": 21, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "ready — ждут worker; retry_wait — в backoff; processing — в аренде; failed — реестр DLQ. Источник истины — PostgreSQL. Единицы: заданий.", "gridPos": { "h": 8, "w": 8, "x": 0, "y": 36 }, "fieldConfig": { "defaults": { "unit": "short", "custom": { "lineWidth": 1, "fillOpacity": 10, "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "max by (state) (last_over_time(messenger_queue_depth{queue=\"attachments.process.v1\"}[30s]))", "legendFormat": "{{state}}", "range": true } ] }, { "type": "timeseries", "title": "Queue lag и возраст старейшего задания", "id": 22, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "lag — сколько самое старое ДОСТУПНОЕ задание ждёт worker (растёт, если worker стоит); oldest_age — с момента постановки (включая backoff). Единицы: секунды.", "gridPos": { "h": 8, "w": 8, "x": 8, "y": 36 }, "fieldConfig": { "defaults": { "unit": "s", "custom": { "lineWidth": 1, "fillOpacity": 10, "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "sli:queue_lag_seconds:max", "legendFormat": "lag (ждёт worker)", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "B", "expr": "sli:queue_oldest_age_seconds:max", "legendFormat": "старейшее незавершённое", "range": true } ] }, { "type": "timeseries", "title": "Брокер и outbox", "id": 23, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "Разрыв DB→broker виден по outbox pending; worker не забирает — по NATS pending. Единицы: сообщений.", "gridPos": { "h": 8, "w": 8, "x": 16, "y": 36 }, "fieldConfig": { "defaults": { "unit": "short", "custom": { "lineWidth": 1, "fillOpacity": 10, "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "max(last_over_time(messenger_broker_pending{queue=\"attachments.process.v1\"}[30s]))", "legendFormat": "NATS: не выдано", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "B", "expr": "max(last_over_time(messenger_broker_ack_pending{queue=\"attachments.process.v1\"}[30s]))", "legendFormat": "NATS: ждут ack", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "C", "expr": "max(last_over_time(messenger_outbox_pending{queue=\"attachments.process.v1\"}[30s]))", "legendFormat": "outbox: не опубликовано", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "D", "expr": "sum by (outcome) (rate(messenger_outbox_publish_total[$__rate_interval])) * 60", "legendFormat": "публикаций/мин {{outcome}}", "range": true } ] }, { "type": "row", "title": "Насыщение ресурсов — пулы БД, worker, CPU/RAM", "id": 24, "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 44 }, "panels": [] }, { "type": "timeseries", "title": "Пул БД: занято / максимум / ждут", "id": 25, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "psycopg_pool по всем репликам сервиса. waiting > 0 — запросы ждут соединения (алерт DbPoolSaturated). Единицы: соединений/запросов.", "gridPos": { "h": 8, "w": 8, "x": 0, "y": 45 }, "fieldConfig": { "defaults": { "unit": "short", "custom": { "lineWidth": 1, "fillOpacity": 10, "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "sum by (service_name) (last_over_time(db_client_connection_count{db_client_connection_state=\"used\"}[30s]))", "legendFormat": "used {{service_name}}", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "B", "expr": "sum by (service_name) (last_over_time(db_client_connection_max[30s]))", "legendFormat": "max {{service_name}}", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "C", "expr": "sum by (service_name) (last_over_time(db_client_connection_pending_requests[30s]))", "legendFormat": "waiting {{service_name}}", "range": true } ] }, { "type": "timeseries", "title": "Worker: занятые слоты / ёмкость", "id": 26, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "Обрабатываемые задания и WORKER_CONCURRENCY × число живых worker. Единицы: слотов.", "gridPos": { "h": 8, "w": 8, "x": 8, "y": 45 }, "fieldConfig": { "defaults": { "unit": "short", "custom": { "lineWidth": 1, "fillOpacity": 10, "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "sum(last_over_time(messenger_worker_busy[30s]))", "legendFormat": "busy", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "B", "expr": "sum(last_over_time(messenger_worker_capacity[30s]))", "legendFormat": "capacity", "range": true } ] }, { "type": "timeseries", "title": "CPU контейнеров", "id": 27, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "container.cpu.time из cgroup (worker — вместе с подпроцессом обработки). Единицы: ядер (1 = одно ядро CPU).", "gridPos": { "h": 8, "w": 8, "x": 16, "y": 45 }, "fieldConfig": { "defaults": { "unit": "short", "custom": { "lineWidth": 1, "fillOpacity": 10, "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "sum by (service_name, service_instance_id) (rate(container_cpu_time_seconds_total[$__rate_interval]))", "legendFormat": "{{service_name}} {{service_instance_id}}", "range": true } ] }, { "type": "timeseries", "title": "Память контейнеров (рабочий набор) и лимит", "id": 28, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "cgroup usage − inactive_file. Единицы: байты.", "gridPos": { "h": 8, "w": 8, "x": 0, "y": 53 }, "fieldConfig": { "defaults": { "unit": "bytes", "custom": { "lineWidth": 1, "fillOpacity": 10, "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "sum by (service_name, service_instance_id) (last_over_time(container_memory_usage_bytes[30s]))", "legendFormat": "{{service_name}} {{service_instance_id}}", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "B", "expr": "max by (service_name) (last_over_time(messenger_container_memory_limit_bytes[30s]))", "legendFormat": "лимит {{service_name}}", "range": true } ] }, { "type": "timeseries", "title": "RSS процессов", "id": 29, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "process.memory.usage (RSS основного процесса). Единицы: байты.", "gridPos": { "h": 8, "w": 8, "x": 8, "y": 53 }, "fieldConfig": { "defaults": { "unit": "bytes", "custom": { "lineWidth": 1, "fillOpacity": 10, "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "sum by (service_name, service_instance_id) (last_over_time(process_memory_usage_bytes[30s]))", "legendFormat": "{{service_name}} {{service_instance_id}}", "range": true } ] }, { "type": "timeseries", "title": "Ожидание соединения пула и таймауты", "id": 30, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "Суммарное время ожидания соединения в секунду (≈ среднее число ждущих) и неудачные получения соединения.", "gridPos": { "h": 8, "w": 8, "x": 16, "y": 53 }, "fieldConfig": { "defaults": { "unit": "short", "custom": { "lineWidth": 1, "fillOpacity": 10, "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "sum by (service_name) (rate(messenger_db_pool_wait_time_seconds_total[$__rate_interval]))", "legendFormat": "ожидание с/с {{service_name}}", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "B", "expr": "sum by (service_name) (rate(db_client_connection_timeouts_total[$__rate_interval]))", "legendFormat": "таймауты/с {{service_name}}", "range": true } ] }, { "type": "row", "title": "Конвейер telemetry — Collector и SDK (потери считаются)", "id": 31, "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 61 }, "panels": [] }, { "type": "timeseries", "title": "Collector: принято / отправлено / ошибки", "id": 32, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "Единицы: элементов/с. Алерт TelemetryExportFailing.", "gridPos": { "h": 8, "w": 8, "x": 0, "y": 62 }, "fieldConfig": { "defaults": { "unit": "short", "custom": { "lineWidth": 1, "fillOpacity": 10, "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "sum(rate(otelcol_receiver_accepted_spans_total[$__rate_interval]))", "legendFormat": "spans принято", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "B", "expr": "sum(rate(otelcol_exporter_sent_spans_total[$__rate_interval]))", "legendFormat": "spans отправлено", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "C", "expr": "sum(rate(otelcol_receiver_accepted_log_records_total[$__rate_interval]))", "legendFormat": "logs принято", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "D", "expr": "sum(rate(otelcol_exporter_sent_log_records_total[$__rate_interval]))", "legendFormat": "logs отправлено", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "E", "expr": "sum(rate(otelcol_receiver_refused_spans_total[$__rate_interval])) + sum(rate(otelcol_receiver_refused_log_records_total[$__rate_interval]))", "legendFormat": "отклонено (memory_limiter)", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "F", "expr": "sum(rate(otelcol_exporter_send_failed_spans_total[$__rate_interval])) + sum(rate(otelcol_exporter_send_failed_log_records_total[$__rate_interval]))", "legendFormat": "не доставлено", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "G", "expr": "sum(rate(otelcol_exporter_enqueue_failed_spans_total[$__rate_interval])) + sum(rate(otelcol_exporter_enqueue_failed_log_records_total[$__rate_interval]))", "legendFormat": "очередь полна", "range": true } ] }, { "type": "timeseries", "title": "Очереди экспортёров Collector", "id": 33, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "Ограниченная очередь sending_queue (батчей). При недоступном backend растёт до ёмкости, затем данные отбрасываются.", "gridPos": { "h": 8, "w": 8, "x": 8, "y": 62 }, "fieldConfig": { "defaults": { "unit": "short", "custom": { "lineWidth": 1, "fillOpacity": 10, "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "sum by (exporter) (otelcol_exporter_queue_size)", "legendFormat": "{{exporter}} размер", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "B", "expr": "max(otelcol_exporter_queue_capacity)", "legendFormat": "ёмкость", "range": true } ] }, { "type": "timeseries", "title": "SDK: отброшено (очередь полна) / ошибки экспорта", "id": 34, "datasource": { "type": "prometheus", "uid": "prometheus" }, "description": "Self-метрики SDK (OTEL_PYTHON_SDK_INTERNAL_METRICS_ENABLED): при недоступном Collector очередь BatchSpanProcessor ограничена — лишнее отбрасывается и считается.", "gridPos": { "h": 8, "w": 8, "x": 16, "y": 62 }, "fieldConfig": { "defaults": { "unit": "short", "custom": { "lineWidth": 1, "fillOpacity": 10, "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" }, "tooltip": { "mode": "multi" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "A", "expr": "sum by (service_name, otel_component_type) (rate(otel_sdk_processor_span_processed_total{error_type!=\"\"}[$__rate_interval]))", "legendFormat": "spans drop {{service_name}}", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "B", "expr": "sum by (service_name) (rate(otel_sdk_processor_log_processed_total{error_type!=\"\"}[$__rate_interval]))", "legendFormat": "logs drop {{service_name}}", "range": true }, { "datasource": { "type": "prometheus", "uid": "prometheus" }, "refId": "C", "expr": "sum by (service_name) (rate(otel_sdk_exporter_span_exported_total{error_type!=\"\"}[$__rate_interval]))", "legendFormat": "spans export error {{service_name}}", "range": true } ] }, { "type": "row", "title": "Логи (Loki) и трассы (Tempo)", "id": 35, "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 70 }, "panels": [] }, { "type": "logs", "title": "Предупреждения и ошибки API/worker", "id": 36, "datasource": { "type": "loki", "uid": "loki" }, "description": "Структурные логи по OTLP: service_name — label; event, request_id, trace_id, job_id — structured metadata. Кнопка trace_id открывает trace в Tempo.", "gridPos": { "h": 10, "w": 14, "x": 0, "y": 71 }, "options": { "showTime": true, "wrapLogMessage": true, "enableLogDetails": true, "sortOrder": "Descending" }, "targets": [ { "datasource": { "type": "loki", "uid": "loki" }, "refId": "A", "expr": "{service_name=~\"messenger-api|messenger-worker\"} | severity_text=~\"WARN|ERROR|FATAL\"" } ] }, { "type": "timeseries", "title": "Объём логов по сервису и уровню", "id": 37, "datasource": { "type": "loki", "uid": "loki" }, "gridPos": { "h": 10, "w": 10, "x": 14, "y": 71 }, "fieldConfig": { "defaults": { "unit": "short", "custom": { "stacking": { "mode": "normal" }, "fillOpacity": 30 } }, "overrides": [] }, "targets": [ { "datasource": { "type": "loki", "uid": "loki" }, "refId": "A", "expr": "sum by (service_name, severity_text) (count_over_time({service_name=~\"messenger-api|messenger-worker\"} [1m]))", "legendFormat": "{{service_name}} {{severity_text}}" } ] }, { "type": "table", "title": "Трассы с ошибками", "id": 38, "datasource": { "type": "tempo", "uid": "tempo" }, "gridPos": { "h": 9, "w": 8, "x": 0, "y": 81 }, "targets": [ { "datasource": { "type": "tempo", "uid": "tempo" }, "refId": "A", "queryType": "traceql", "query": "{ resource.service.name =~ \"messenger-.*\" && status = error }", "limit": 20, "tableType": "traces" } ] }, { "type": "table", "title": "Медленные запросы API > 250 мс", "id": 39, "datasource": { "type": "tempo", "uid": "tempo" }, "gridPos": { "h": 9, "w": 8, "x": 8, "y": 81 }, "targets": [ { "datasource": { "type": "tempo", "uid": "tempo" }, "refId": "A", "queryType": "traceql", "query": "{ resource.service.name = \"messenger-api\" && kind = server && duration > 250ms }", "limit": 20, "tableType": "traces" } ] }, { "type": "table", "title": "Загрузка → worker (pipeline вложений)", "id": 40, "datasource": { "type": "tempo", "uid": "tempo" }, "gridPos": { "h": 9, "w": 8, "x": 16, "y": 81 }, "targets": [ { "datasource": { "type": "tempo", "uid": "tempo" }, "refId": "A", "queryType": "traceql", "query": "{ span.messaging.operation.type = \"process\" }", "limit": 20, "tableType": "traces" } ] } ] }