{ "uid": "messenger-lab6", "title": "Messenger — lab6", "tags": [ "messenger", "lab6", "otel" ], "timezone": "browser", "schemaVersion": 39, "version": 1, "editable": false, "refresh": "10s", "time": { "from": "now-30m", "to": "now" }, "graphTooltip": 1, "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 — сводка", "id": 1, "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 0 }, "panels": [] }, { "type": "stat", "title": "Доступность API за 1h (SLO ≥ 99 %)", "id": 2, "datasource": { "type": "prometheus", "uid": "prom" }, "description": "SLI = 1 − 5xx / все запросы API (health исключены). Recording rule messenger:http_errors:ratio1h.", "gridPos": { "h": 4, "w": 6, "x": 0, "y": 1 }, "fieldConfig": { "defaults": { "unit": "percentunit", "thresholds": { "mode": "absolute", "steps": [ { "color": "red", "value": null }, { "color": "green", "value": 0.99 } ] }, "decimals": 3 }, "overrides": [] }, "options": { "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "", "values": false }, "colorMode": "background", "graphMode": "area", "textMode": "value" }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "A", "expr": "1 - messenger:http_errors:ratio1h", "instant": false, "range": true } ] }, { "type": "stat", "title": "API p95 за 5m (SLO < 500 ms)", "id": 3, "datasource": { "type": "prometheus", "uid": "prom" }, "description": "histogram_quantile(0.95, sum by (le) (rate(...bucket[5m]))) — по buckets всех реплик.", "gridPos": { "h": 4, "w": 6, "x": 6, "y": 1 }, "fieldConfig": { "defaults": { "unit": "s", "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "orange", "value": 0.3 }, { "color": "red", "value": 0.5 } ] } }, "overrides": [] }, "options": { "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "", "values": false }, "colorMode": "background", "graphMode": "area", "textMode": "value" }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "A", "expr": "messenger:http_latency_seconds:p95_5m", "instant": false, "range": true } ] }, { "type": "stat", "title": "Upload → ready p95 за 15m (SLO < 30 s)", "id": 4, "datasource": { "type": "prometheus", "uid": "prom" }, "description": "", "gridPos": { "h": 4, "w": 6, "x": 12, "y": 1 }, "fieldConfig": { "defaults": { "unit": "s", "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "orange", "value": 15 }, { "color": "red", "value": 30 } ] } }, "overrides": [] }, "options": { "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "", "values": false }, "colorMode": "background", "graphMode": "area", "textMode": "value" }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "A", "expr": "messenger:time_to_ready_seconds:p95_15m", "instant": false, "range": true } ] }, { "type": "stat", "title": "Возраст старейшей job (alert > 60 s)", "id": 5, "datasource": { "type": "prometheus", "uid": "prom" }, "description": "", "gridPos": { "h": 4, "w": 6, "x": 18, "y": 1 }, "fieldConfig": { "defaults": { "unit": "s", "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "orange", "value": 30 }, { "color": "red", "value": 60 } ] } }, "overrides": [] }, "options": { "reduceOptions": { "calcs": [ "lastNotNull" ], "fields": "", "values": false }, "colorMode": "background", "graphMode": "area", "textMode": "value" }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "A", "expr": "max(messenger:queue_oldest_age_seconds:max)", "instant": false, "range": true } ] }, { "type": "row", "title": "API — RED", "id": 6, "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 5 }, "panels": [] }, { "type": "timeseries", "title": "RPS по маршруту", "id": 7, "datasource": { "type": "prometheus", "uid": "prom" }, "description": "rate(http_server_request_duration_seconds_count) по шаблону маршрута; health не инструментирован.", "gridPos": { "h": 8, "w": 8, "x": 0, "y": 6 }, "fieldConfig": { "defaults": { "unit": "reqps", "custom": { "lineWidth": 2, "fillOpacity": 10, "showPoints": "never", "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "table", "placement": "bottom", "calcs": [ "lastNotNull", "max" ] }, "tooltip": { "mode": "multi", "sort": "desc" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "A", "expr": "sum by (http_route) (rate(http_server_request_duration_seconds_count[$__rate_interval]))", "legendFormat": "{{http_route}}", "range": true } ] }, { "type": "timeseries", "title": "Доля 5xx (SLI ошибок)", "id": 8, "datasource": { "type": "prometheus", "uid": "prom" }, "description": "numerator: 5xx; denominator: все бизнес-запросы. Порог alert ApiHighErrorRate = 5 %.", "gridPos": { "h": 8, "w": 8, "x": 8, "y": 6 }, "fieldConfig": { "defaults": { "unit": "percentunit", "custom": { "lineWidth": 2, "fillOpacity": 10, "showPoints": "never", "stacking": { "mode": "none" }, "thresholdsStyle": { "mode": "line+area" } }, "min": 0, "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 0.05 } ] } }, "overrides": [] }, "options": { "legend": { "displayMode": "table", "placement": "bottom", "calcs": [ "lastNotNull", "max" ] }, "tooltip": { "mode": "multi", "sort": "desc" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "A", "expr": "(sum(rate(http_server_request_duration_seconds_count{http_response_status_code=~\"5..\"}[$__rate_interval])) or vector(0)) / sum(rate(http_server_request_duration_seconds_count[$__rate_interval]))", "legendFormat": "5xx / все", "range": true }, { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "B", "expr": "(sum(rate(http_server_request_duration_seconds_count{http_response_status_code=~\"4..\"}[$__rate_interval])) or vector(0)) / sum(rate(http_server_request_duration_seconds_count[$__rate_interval]))", "legendFormat": "4xx / все (не ошибка сервиса)", "range": true } ] }, { "type": "timeseries", "title": "Latency p50 / p95 / p99", "id": 9, "datasource": { "type": "prometheus", "uid": "prom" }, "description": "Перцентили из суммы buckets всех реплик, не среднее p95 по репликам.", "gridPos": { "h": 8, "w": 8, "x": 16, "y": 6 }, "fieldConfig": { "defaults": { "unit": "s", "custom": { "lineWidth": 2, "fillOpacity": 10, "showPoints": "never", "stacking": { "mode": "none" }, "thresholdsStyle": { "mode": "line+area" } }, "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 0.5 } ] } }, "overrides": [] }, "options": { "legend": { "displayMode": "table", "placement": "bottom", "calcs": [ "lastNotNull", "max" ] }, "tooltip": { "mode": "multi", "sort": "desc" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "A", "expr": "histogram_quantile(0.5, sum by (le) (rate(http_server_request_duration_seconds_bucket[$__rate_interval])))", "legendFormat": "p50", "range": true }, { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "B", "expr": "histogram_quantile(0.95, sum by (le) (rate(http_server_request_duration_seconds_bucket[$__rate_interval])))", "legendFormat": "p95", "range": true }, { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "C", "expr": "histogram_quantile(0.99, sum by (le) (rate(http_server_request_duration_seconds_bucket[$__rate_interval])))", "legendFormat": "p99", "range": true } ] }, { "type": "timeseries", "title": "Ответы 5xx по маршруту", "id": 10, "datasource": { "type": "prometheus", "uid": "prom" }, "description": "", "gridPos": { "h": 8, "w": 12, "x": 0, "y": 14 }, "fieldConfig": { "defaults": { "unit": "reqps", "custom": { "lineWidth": 2, "fillOpacity": 10, "showPoints": "never", "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "table", "placement": "bottom", "calcs": [ "lastNotNull", "max" ] }, "tooltip": { "mode": "multi", "sort": "desc" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "A", "expr": "sum by (http_route, http_response_status_code) (rate(http_server_request_duration_seconds_count{http_response_status_code=~\"5..\"}[$__rate_interval]))", "legendFormat": "{{http_route}} {{http_response_status_code}}", "range": true } ] }, { "type": "timeseries", "title": "p95 по маршруту", "id": 11, "datasource": { "type": "prometheus", "uid": "prom" }, "description": "", "gridPos": { "h": 8, "w": 12, "x": 12, "y": 14 }, "fieldConfig": { "defaults": { "unit": "s", "custom": { "lineWidth": 2, "fillOpacity": 10, "showPoints": "never", "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "table", "placement": "bottom", "calcs": [ "lastNotNull", "max" ] }, "tooltip": { "mode": "multi", "sort": "desc" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "A", "expr": "histogram_quantile(0.95, sum by (le, http_route) (rate(http_server_request_duration_seconds_bucket[$__rate_interval])))", "legendFormat": "{{http_route}}", "range": true } ] }, { "type": "row", "title": "Очередь и worker", "id": 12, "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 22 }, "panels": [] }, { "type": "timeseries", "title": "Jobs по outcome", "id": 13, "datasource": { "type": "prometheus", "uid": "prom" }, "description": "messenger.jobs.processed {job.type, outcome}: ready / retry / failed / duplicate / lease_lost.", "gridPos": { "h": 8, "w": 8, "x": 0, "y": 23 }, "fieldConfig": { "defaults": { "unit": "ops", "custom": { "lineWidth": 2, "fillOpacity": 10, "showPoints": "never", "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "table", "placement": "bottom", "calcs": [ "lastNotNull", "max" ] }, "tooltip": { "mode": "multi", "sort": "desc" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "A", "expr": "sum by (outcome) (rate(messenger_jobs_processed_total[$__rate_interval]))", "legendFormat": "{{outcome}}", "range": true } ] }, { "type": "timeseries", "title": "Длительность job p50/p95 по outcome", "id": 14, "datasource": { "type": "prometheus", "uid": "prom" }, "description": "", "gridPos": { "h": 8, "w": 8, "x": 8, "y": 23 }, "fieldConfig": { "defaults": { "unit": "s", "custom": { "lineWidth": 2, "fillOpacity": 10, "showPoints": "never", "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "table", "placement": "bottom", "calcs": [ "lastNotNull", "max" ] }, "tooltip": { "mode": "multi", "sort": "desc" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "A", "expr": "histogram_quantile(0.5, sum by (le, outcome) (rate(messenger_job_duration_seconds_bucket[$__rate_interval])))", "legendFormat": "p50 {{outcome}}", "range": true }, { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "B", "expr": "histogram_quantile(0.95, sum by (le, outcome) (rate(messenger_job_duration_seconds_bucket[$__rate_interval])))", "legendFormat": "p95 {{outcome}}", "range": true } ] }, { "type": "timeseries", "title": "Upload → ready p50/p95", "id": 15, "datasource": { "type": "prometheus", "uid": "prom" }, "description": "От COMMIT (202, durable acceptance) до status=ready. Время ожидания в очереди включено.", "gridPos": { "h": 8, "w": 8, "x": 16, "y": 23 }, "fieldConfig": { "defaults": { "unit": "s", "custom": { "lineWidth": 2, "fillOpacity": 10, "showPoints": "never", "stacking": { "mode": "none" }, "thresholdsStyle": { "mode": "line+area" } }, "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 30 } ] } }, "overrides": [] }, "options": { "legend": { "displayMode": "table", "placement": "bottom", "calcs": [ "lastNotNull", "max" ] }, "tooltip": { "mode": "multi", "sort": "desc" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "A", "expr": "histogram_quantile(0.5, sum by (le) (rate(messenger_attachment_time_to_ready_seconds_bucket[$__rate_interval])))", "legendFormat": "p50", "range": true }, { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "B", "expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_attachment_time_to_ready_seconds_bucket[$__rate_interval])))", "legendFormat": "p95", "range": true } ] }, { "type": "timeseries", "title": "Глубина очереди по состоянию", "id": 16, "datasource": { "type": "prometheus", "uid": "prom" }, "description": "queued / processing / outbox_unpublished из attachment_jobs и job_outbox (gauge публикует API, max по репликам).", "gridPos": { "h": 8, "w": 12, "x": 0, "y": 31 }, "fieldConfig": { "defaults": { "unit": "short", "custom": { "lineWidth": 2, "fillOpacity": 10, "showPoints": "never", "stacking": { "mode": "normal" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "table", "placement": "bottom", "calcs": [ "lastNotNull", "max" ] }, "tooltip": { "mode": "multi", "sort": "desc" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "A", "expr": "max by (state) (messenger_queue_depth)", "legendFormat": "{{state}}", "range": true } ] }, { "type": "timeseries", "title": "Возраст старейшей job", "id": 17, "datasource": { "type": "prometheus", "uid": "prom" }, "description": "Backlog ≠ latency: возраст растёт, даже если depth небольшой. Alert AttachmentQueueLagGrowing > 60 s for 30s.", "gridPos": { "h": 8, "w": 12, "x": 12, "y": 31 }, "fieldConfig": { "defaults": { "unit": "s", "custom": { "lineWidth": 2, "fillOpacity": 10, "showPoints": "never", "stacking": { "mode": "none" }, "thresholdsStyle": { "mode": "line+area" } }, "min": 0, "thresholds": { "mode": "absolute", "steps": [ { "color": "green", "value": null }, { "color": "red", "value": 60 } ] } }, "overrides": [] }, "options": { "legend": { "displayMode": "table", "placement": "bottom", "calcs": [ "lastNotNull", "max" ] }, "tooltip": { "mode": "multi", "sort": "desc" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "A", "expr": "messenger:queue_oldest_age_seconds:max", "legendFormat": "{{queue}}", "range": true } ] }, { "type": "row", "title": "Насыщение", "id": 18, "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 39 }, "panels": [] }, { "type": "timeseries", "title": "DB pool: used / idle / waiting / max", "id": 19, "datasource": { "type": "prometheus", "uid": "prom" }, "description": "psycopg_pool.get_stats(): pool_size−pool_available = used; requests_waiting = waiting.", "gridPos": { "h": 8, "w": 8, "x": 0, "y": 40 }, "fieldConfig": { "defaults": { "unit": "short", "custom": { "lineWidth": 2, "fillOpacity": 10, "showPoints": "never", "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "table", "placement": "bottom", "calcs": [ "lastNotNull", "max" ] }, "tooltip": { "mode": "multi", "sort": "desc" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "A", "expr": "sum by (job, instance, state) (messenger_db_pool_connections)", "legendFormat": "{{instance}} {{state}}", "range": true }, { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "B", "expr": "sum by (job, instance) (messenger_db_pool_waiting)", "legendFormat": "{{instance}} waiting", "range": true }, { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "C", "expr": "max by (job) (messenger_db_pool_max)", "legendFormat": "{{job}} max", "range": true } ] }, { "type": "timeseries", "title": "Worker busy / capacity", "id": 20, "datasource": { "type": "prometheus", "uid": "prom" }, "description": "", "gridPos": { "h": 8, "w": 8, "x": 8, "y": 40 }, "fieldConfig": { "defaults": { "unit": "short", "custom": { "lineWidth": 2, "fillOpacity": 10, "showPoints": "never", "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "table", "placement": "bottom", "calcs": [ "lastNotNull", "max" ] }, "tooltip": { "mode": "multi", "sort": "desc" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "A", "expr": "sum by (instance) (messenger_worker_busy)", "legendFormat": "{{instance}} busy", "range": true }, { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "B", "expr": "sum by (instance) (messenger_worker_capacity)", "legendFormat": "{{instance}} capacity", "range": true }, { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "C", "expr": "sum(messenger_worker_busy) / sum(messenger_worker_capacity)", "legendFormat": "утилизация", "range": true } ] }, { "type": "timeseries", "title": "CPU процессов (ядра)", "id": 21, "datasource": { "type": "prometheus", "uid": "prom" }, "description": "process.cpu.time (user+system) из system-metrics instrumentation; 1 = одно ядро.", "gridPos": { "h": 8, "w": 8, "x": 16, "y": 40 }, "fieldConfig": { "defaults": { "unit": "short", "custom": { "lineWidth": 2, "fillOpacity": 10, "showPoints": "never", "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "table", "placement": "bottom", "calcs": [ "lastNotNull", "max" ] }, "tooltip": { "mode": "multi", "sort": "desc" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "A", "expr": "sum by (job, instance) (rate(process_cpu_time_seconds_total{job=~\"messenger-.+\"}[$__rate_interval]))", "legendFormat": "{{instance}}", "range": true } ] }, { "type": "timeseries", "title": "RSS процессов", "id": 22, "datasource": { "type": "prometheus", "uid": "prom" }, "description": "", "gridPos": { "h": 8, "w": 12, "x": 0, "y": 48 }, "fieldConfig": { "defaults": { "unit": "bytes", "custom": { "lineWidth": 2, "fillOpacity": 10, "showPoints": "never", "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "table", "placement": "bottom", "calcs": [ "lastNotNull", "max" ] }, "tooltip": { "mode": "multi", "sort": "desc" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "A", "expr": "process_memory_usage_bytes{job=~\"messenger-.+\"}", "legendFormat": "{{instance}}", "range": true }, { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "B", "expr": "otelcol_process_memory_rss{job=\"otel-collector\"}", "legendFormat": "otel-collector", "range": true } ] }, { "type": "timeseries", "title": "Collector: отправлено / потеряно по exporter", "id": 23, "datasource": { "type": "prometheus", "uid": "prom" }, "description": "Потери telemetry при недоступном backend: send_failed растёт, queue_size ограничен queue_capacity.", "gridPos": { "h": 8, "w": 12, "x": 12, "y": 48 }, "fieldConfig": { "defaults": { "unit": "short", "custom": { "lineWidth": 2, "fillOpacity": 10, "showPoints": "never", "stacking": { "mode": "none" } } }, "overrides": [] }, "options": { "legend": { "displayMode": "table", "placement": "bottom", "calcs": [ "lastNotNull", "max" ] }, "tooltip": { "mode": "multi", "sort": "desc" } }, "targets": [ { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "A", "expr": "sum by (exporter) (rate({__name__=~\"otelcol_exporter_sent_.+\"}[$__rate_interval]))", "legendFormat": "sent {{exporter}}", "range": true }, { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "B", "expr": "sum by (exporter) (rate({__name__=~\"otelcol_exporter_send_failed_.+\"}[$__rate_interval]))", "legendFormat": "FAILED {{exporter}}", "range": true }, { "datasource": { "type": "prometheus", "uid": "prom" }, "refId": "C", "expr": "sum by (exporter) (otelcol_exporter_queue_size)", "legendFormat": "queue {{exporter}}", "range": true } ] }, { "type": "row", "title": "Логи и трассы", "id": 24, "collapsed": false, "gridPos": { "h": 1, "w": 24, "x": 0, "y": 56 }, "panels": [] }, { "type": "logs", "title": "Логи API и worker (WARN/ERROR и события задач)", "id": 25, "datasource": { "type": "loki", "uid": "loki" }, "gridPos": { "h": 10, "w": 24, "x": 0, "y": 57 }, "options": { "showTime": true, "wrapLogMessage": true, "enableLogDetails": true, "sortOrder": "Descending", "dedupStrategy": "none", "prettifyLogMessage": false }, "targets": [ { "datasource": { "type": "loki", "uid": "loki" }, "refId": "A", "queryType": "range", "expr": "{service_name=~\"messenger-.+\"} | severity_number >= 13 or event=~\"job\\\\..+|attachment\\\\..+\"" } ] }, { "type": "table", "title": "Последние трассы upload (Tempo, TraceQL)", "id": 26, "datasource": { "type": "tempo", "uid": "tempo" }, "gridPos": { "h": 9, "w": 24, "x": 0, "y": 67 }, "targets": [ { "datasource": { "type": "tempo", "uid": "tempo" }, "refId": "A", "queryType": "traceql", "limit": 20, "tableType": "traces", "query": "{resource.service.name=\"messenger-api\" && name=\"POST /api/v1/chats/{chat_id}/attachments\"}" } ] } ] }