{ "uid": "messenger-lab6", "title": "Messenger — API, worker, очередь", "schemaVersion": 39, "version": 2, "editable": true, "time": { "from": "now-30m", "to": "now" }, "refresh": "10s", "tags": [ "messenger", "lab6" ], "panels": [ { "id": 1, "type": "timeseries", "title": "API: запросы/с по маршруту и классу статуса", "description": "http.server.request.duration (count), все реплики; health исключён", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 0, "y": 0, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "reqps" }, "overrides": [] }, "targets": [ { "refId": "A", "expr": "sum by (http_route, class) (label_replace(rate(http_server_request_duration_seconds_count{job=\"messenger-api\",http_route!~\"/health.*\"}[1m]), \"class\", \"${1}xx\", \"http_response_status_code\", \"([0-9]).*\"))", "legendFormat": "{{http_route}} {{class}}", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "id": 2, "type": "timeseries", "title": "API: доля 5xx (без health)", "description": "numerator: ответы 5xx; denominator: все бизнес-запросы, кроме /health/*", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 12, "y": 0, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "percentunit" }, "overrides": [] }, "targets": [ { "refId": "A", "expr": "sum(rate(http_server_request_duration_seconds_count{job=\"messenger-api\",http_route!~\"/health.*\",http_response_status_code=~\"5..\"}[5m])) / sum(rate(http_server_request_duration_seconds_count{job=\"messenger-api\",http_route!~\"/health.*\"}[5m]))", "legendFormat": "5xx / все", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "id": 3, "type": "timeseries", "title": "API: длительность p50/p95/p99 (из histogram, все реплики)", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 0, "y": 8, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "s" }, "overrides": [] }, "targets": [ { "refId": "A", "expr": "histogram_quantile(0.5, sum by (le) (rate(http_server_request_duration_seconds_bucket{job=\"messenger-api\",http_route!~\"/health.*\"}[5m])))", "legendFormat": "p50", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "refId": "B", "expr": "histogram_quantile(0.95, sum by (le) (rate(http_server_request_duration_seconds_bucket{job=\"messenger-api\",http_route!~\"/health.*\"}[5m])))", "legendFormat": "p95", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "refId": "C", "expr": "histogram_quantile(0.99, sum by (le) (rate(http_server_request_duration_seconds_bucket{job=\"messenger-api\",http_route!~\"/health.*\"}[5m])))", "legendFormat": "p99", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "id": 4, "type": "timeseries", "title": "Worker: задания по исходу", "description": "messenger.jobs.processed: done / retry / failed / duplicate / fenced", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 12, "y": 8, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "ops" }, "overrides": [] }, "targets": [ { "refId": "A", "expr": "sum by (outcome) (rate(messenger_jobs_processed_total{job=\"messenger-worker\"}[5m]))", "legendFormat": "{{outcome}}", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "id": 5, "type": "timeseries", "title": "Worker: длительность попытки p50/p95/p99", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 0, "y": 16, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "s" }, "overrides": [] }, "targets": [ { "refId": "A", "expr": "histogram_quantile(0.5, sum by (le) (rate(messenger_job_duration_seconds_bucket{job=\"messenger-worker\"}[5m])))", "legendFormat": "p50", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "refId": "B", "expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_job_duration_seconds_bucket{job=\"messenger-worker\"}[5m])))", "legendFormat": "p95", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "refId": "C", "expr": "histogram_quantile(0.99, sum by (le) (rate(messenger_job_duration_seconds_bucket{job=\"messenger-worker\"}[5m])))", "legendFormat": "p99", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "id": 6, "type": "timeseries", "title": "Очередь: глубина и возраст самого старого задания", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 12, "y": 16, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "short" }, "overrides": [] }, "targets": [ { "refId": "A", "expr": "max(messenger_queue_depth)", "legendFormat": "queued, шт", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "refId": "B", "expr": "max(messenger_queue_oldest_age_seconds)", "legendFormat": "oldest age, с", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "id": 7, "type": "timeseries", "title": "Worker: занятость (busy / capacity)", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 0, "y": 24, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "percentunit" }, "overrides": [] }, "targets": [ { "refId": "A", "expr": "sum(messenger_worker_busy{job=\"messenger-worker\"}) / sum(messenger_worker_capacity{job=\"messenger-worker\"})", "legendFormat": "busy / capacity", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "id": 8, "type": "timeseries", "title": "Время до ready p50/p95 (от 202 до ready)", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 12, "y": 24, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "s" }, "overrides": [] }, "targets": [ { "refId": "A", "expr": "histogram_quantile(0.5, sum by (le) (rate(messenger_attachment_time_to_ready_seconds_bucket{job=\"messenger-worker\"}[5m])))", "legendFormat": "p50", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "refId": "B", "expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_attachment_time_to_ready_seconds_bucket{job=\"messenger-worker\"}[5m])))", "legendFormat": "p95", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "id": 9, "type": "timeseries", "title": "Пул соединений БД (Hikari)", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 0, "y": 32, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "short" }, "overrides": [] }, "targets": [ { "refId": "A", "expr": "sum by (job, state) (db_client_connections_usage)", "legendFormat": "{{job}} {{state}}", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "refId": "B", "expr": "sum by (job) (db_client_connections_pending_requests)", "legendFormat": "{{job}} waiting", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "id": 10, "type": "timeseries", "title": "JVM: CPU и память", "description": "", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 12, "y": 32, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "short" }, "overrides": [] }, "targets": [ { "refId": "A", "expr": "avg by (job, host_name) (jvm_cpu_recent_utilization_ratio)", "legendFormat": "CPU {{job}} {{host_name}}", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "refId": "B", "expr": "sum by (job, host_name) (jvm_memory_used_bytes) / 1048576", "legendFormat": "heap+non-heap MiB {{job}} {{host_name}}", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "id": 11, "type": "logs", "title": "Логи API и worker (Loki, со ссылкой на trace)", "datasource": { "type": "loki", "uid": "loki" }, "gridPos": { "x": 0, "y": 40, "w": 24, "h": 10 }, "options": { "showTime": true, "wrapLogMessage": true }, "targets": [ { "refId": "A", "expr": "{service_name=~\"messenger-api|messenger-worker\"}", "datasource": { "type": "loki", "uid": "loki" } } ] }, { "id": 12, "type": "timeseries", "title": "SLO доступности API: burn rate (page ≥ 14.4 за 2m30s+30s, ticket ≥ 6 за 15m+1m30s)", "description": "burn = доля 5xx (без /health) / бюджет 1 %; окна — SRE Workbook, сжатые в 24 раза (см. infra/prometheus/alerts.yml)", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 0, "y": 50, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "x", "min": 0 }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" } }, "targets": [ { "refId": "A", "expr": "slo:api_errors:ratio_rate30s / 0.01", "legendFormat": "burn 30s", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "refId": "B", "expr": "slo:api_errors:ratio_rate2m30s / 0.01", "legendFormat": "burn 2m30s", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "refId": "C", "expr": "slo:api_errors:ratio_rate1m30s / 0.01", "legendFormat": "burn 1m30s", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "refId": "D", "expr": "slo:api_errors:ratio_rate15m / 0.01", "legendFormat": "burn 15m", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] }, { "id": 13, "type": "timeseries", "title": "SLO времени до ready ≤ 10 с: burn rate (те же пороги)", "description": "burn = доля вложений с временем до ready > 10 с / бюджет 1 %; события появляются только при ready", "datasource": { "type": "prometheus", "uid": "prometheus" }, "gridPos": { "x": 12, "y": 50, "w": 12, "h": 8 }, "fieldConfig": { "defaults": { "unit": "x", "min": 0 }, "overrides": [] }, "options": { "legend": { "displayMode": "list", "placement": "bottom" } }, "targets": [ { "refId": "A", "expr": "slo:ttr_slow:ratio_rate30s / 0.01", "legendFormat": "burn 30s", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "refId": "B", "expr": "slo:ttr_slow:ratio_rate2m30s / 0.01", "legendFormat": "burn 2m30s", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "refId": "C", "expr": "slo:ttr_slow:ratio_rate1m30s / 0.01", "legendFormat": "burn 1m30s", "datasource": { "type": "prometheus", "uid": "prometheus" } }, { "refId": "D", "expr": "slo:ttr_slow:ratio_rate15m / 0.01", "legendFormat": "burn 15m", "datasource": { "type": "prometheus", "uid": "prometheus" } } ] } ] }