Files
mtusi2026lab6/infra/grafana/dashboards/messenger.json
T

917 lines
18 KiB
JSON

{
"uid": "messenger-overview",
"title": "Messenger: API, очередь, worker",
"tags": [
"messenger",
"lab6"
],
"timezone": "browser",
"schemaVersion": 39,
"version": 1,
"refresh": "5s",
"time": {
"from": "now-15m",
"to": "now"
},
"panels": [
{
"id": 1,
"type": "row",
"title": "API (бизнес-запросы без /health) — запросы, ошибки, задержки",
"gridPos": {
"x": 0,
"y": 0,
"w": 24,
"h": 1
},
"collapsed": false,
"panels": []
},
{
"id": 2,
"type": "timeseries",
"title": "RPS по маршрутам",
"description": "Единицы: запросов в секунду. Источник: http_server_request_duration_seconds_count.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 1,
"w": 8,
"h": 7
},
"targets": [
{
"refId": "A",
"expr": "sum by (http_route) (rate(http_server_request_duration_seconds_count{http_route!~\"/health.*\"}[1m]))",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"legendFormat": "{{http_route}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "reqps",
"custom": {
"lineWidth": 1,
"fillOpacity": 10
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 3,
"type": "timeseries",
"title": "Доля ошибок 5xx (SLI)",
"description": "Числитель: 5xx; знаменатель: все запросы кроме /health. 4xx (в т.ч. неверный пароль) не считаются отказом сервиса.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 8,
"y": 1,
"w": 8,
"h": 7
},
"targets": [
{
"refId": "A",
"expr": "sli:http_error_ratio:1m",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"legendFormat": ""
}
],
"fieldConfig": {
"defaults": {
"unit": "percentunit",
"custom": {
"lineWidth": 1,
"fillOpacity": 10
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 0.05
}
]
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 4,
"type": "timeseries",
"title": "Latency p50 / p95 / p99",
"description": "Процентили считаются из суммарной гистограммы всех реплик (sum by le), а не усреднением p95 реплик.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 16,
"y": 1,
"w": 8,
"h": 7
},
"targets": [
{
"refId": "A",
"expr": "histogram_quantile(0.50, sum by (le) (rate(http_server_request_duration_seconds_bucket{http_route!~\"/health.*\"}[1m])))",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"legendFormat": "p50"
},
{
"refId": "B",
"expr": "histogram_quantile(0.95, sum by (le) (rate(http_server_request_duration_seconds_bucket{http_route!~\"/health.*\"}[1m])))",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"legendFormat": "p95"
},
{
"refId": "C",
"expr": "histogram_quantile(0.99, sum by (le) (rate(http_server_request_duration_seconds_bucket{http_route!~\"/health.*\"}[1m])))",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"legendFormat": "p99"
}
],
"fieldConfig": {
"defaults": {
"unit": "s",
"custom": {
"lineWidth": 1,
"fillOpacity": 10
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 5,
"type": "timeseries",
"title": "RPS по статус-кодам",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 8,
"w": 8,
"h": 7
},
"targets": [
{
"refId": "A",
"expr": "sum by (http_response_status_code) (rate(http_server_request_duration_seconds_count{http_route!~\"/health.*\"}[1m]))",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"legendFormat": "{{http_response_status_code}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "reqps",
"custom": {
"lineWidth": 1,
"fillOpacity": 10
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 6,
"type": "timeseries",
"title": "Latency p95 по маршрутам",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 8,
"y": 8,
"w": 8,
"h": 7
},
"targets": [
{
"refId": "A",
"expr": "histogram_quantile(0.95, sum by (le, http_route) (rate(http_server_request_duration_seconds_bucket{http_route!~\"/health.*\"}[1m])))",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"legendFormat": "{{http_route}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "s",
"custom": {
"lineWidth": 1,
"fillOpacity": 10
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 7,
"type": "timeseries",
"title": "DB pool: занято / простаивает / ожидают",
"description": "Пул соединений PostgreSQL по всем репликам API. Рост waiting — насыщение пула.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 16,
"y": 8,
"w": 8,
"h": 7
},
"targets": [
{
"refId": "A",
"expr": "sum(db_client_connections_usage{state=\"used\"})",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"legendFormat": "used"
},
{
"refId": "B",
"expr": "sum(db_client_connections_usage{state=\"idle\"})",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"legendFormat": "idle"
},
{
"refId": "C",
"expr": "sum(db_client_connections_waiting)",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"legendFormat": "waiting"
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"custom": {
"lineWidth": 1,
"fillOpacity": 10
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 8,
"type": "row",
"title": "Задания (worker) и очередь",
"gridPos": {
"x": 0,
"y": 15,
"w": 24,
"h": 1
},
"collapsed": false,
"panels": []
},
{
"id": 9,
"type": "timeseries",
"title": "Задания по исходам",
"description": "ready — успешно; failed — финальная ошибка; retried — временная ошибка, запланирован повтор; noop — повторная доставка.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 16,
"w": 8,
"h": 7
},
"targets": [
{
"refId": "A",
"expr": "sum by (outcome) (rate(messenger_jobs_processed_total[1m]))",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"legendFormat": "{{outcome}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "ops",
"custom": {
"lineWidth": 1,
"fillOpacity": 10
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 10,
"type": "timeseries",
"title": "Длительность обработки p50 / p95 (worker)",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 8,
"y": 16,
"w": 8,
"h": 7
},
"targets": [
{
"refId": "A",
"expr": "histogram_quantile(0.50, sum by (le) (rate(messenger_job_duration_seconds_bucket[1m])))",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"legendFormat": "p50"
},
{
"refId": "B",
"expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_job_duration_seconds_bucket[1m])))",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"legendFormat": "p95"
}
],
"fieldConfig": {
"defaults": {
"unit": "s",
"custom": {
"lineWidth": 1,
"fillOpacity": 10
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 11,
"type": "timeseries",
"title": "Время до ready p50 / p95",
"description": "От устойчивого приёма загрузки (202) до ready. Включает ожидание в очереди.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 16,
"y": 16,
"w": 8,
"h": 7
},
"targets": [
{
"refId": "A",
"expr": "histogram_quantile(0.50, sum by (le) (rate(messenger_job_time_to_ready_seconds_bucket[1m])))",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"legendFormat": "p50"
},
{
"refId": "B",
"expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_job_time_to_ready_seconds_bucket[1m])))",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"legendFormat": "p95"
}
],
"fieldConfig": {
"defaults": {
"unit": "s",
"custom": {
"lineWidth": 1,
"fillOpacity": 10
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 12,
"type": "timeseries",
"title": "Глубина очереди (queued + processing)",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 23,
"w": 8,
"h": 7
},
"targets": [
{
"refId": "A",
"expr": "max(messenger_queue_depth)",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"legendFormat": "jobs"
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"custom": {
"lineWidth": 1,
"fillOpacity": 10
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 13,
"type": "timeseries",
"title": "Возраст старейшей задачи",
"description": "Backlog — не задержка обработки: показывает, как долго ждёт самое старое задание.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 8,
"y": 23,
"w": 8,
"h": 7
},
"targets": [
{
"refId": "A",
"expr": "max(messenger_queue_oldest_job_age_seconds)",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"legendFormat": "oldest"
}
],
"fieldConfig": {
"defaults": {
"unit": "s",
"custom": {
"lineWidth": 1,
"fillOpacity": 10
},
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 30
}
]
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 14,
"type": "timeseries",
"title": "Worker: занято / ёмкость",
"description": "Насыщение worker: busy == capacity при растущей очереди означает нехватку мощности.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 16,
"y": 23,
"w": 8,
"h": 7
},
"targets": [
{
"refId": "A",
"expr": "sum(messenger_worker_busy)",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"legendFormat": "busy"
},
{
"refId": "B",
"expr": "sum(messenger_worker_capacity)",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"legendFormat": "capacity"
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"custom": {
"lineWidth": 1,
"fillOpacity": 10
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 15,
"type": "row",
"title": "Ресурсы процессов",
"gridPos": {
"x": 0,
"y": 30,
"w": 24,
"h": 1
},
"collapsed": false,
"panels": []
},
{
"id": 16,
"type": "timeseries",
"title": "RSS по сервисам",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 31,
"w": 8,
"h": 7
},
"targets": [
{
"refId": "A",
"expr": "sum by (service_name) (process_memory_rss_bytes)",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"legendFormat": "{{service_name}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "bytes",
"custom": {
"lineWidth": 1,
"fillOpacity": 10
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 17,
"type": "timeseries",
"title": "CPU по сервисам (ядра)",
"description": "rate накопленного CPU-времени процесса: 1.0 = одно ядро.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 8,
"y": 31,
"w": 8,
"h": 7
},
"targets": [
{
"refId": "A",
"expr": "sum by (service_name) (rate(process_cpu_time_seconds_total[1m]))",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"legendFormat": "{{service_name}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"custom": {
"lineWidth": 1,
"fillOpacity": 10
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 18,
"type": "timeseries",
"title": "Collector: очередь экспорта и отказы",
"description": "Поведение Collector при недоступном backend: ограниченная очередь, отказы, memory_limiter.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 16,
"y": 31,
"w": 8,
"h": 7
},
"targets": [
{
"refId": "A",
"expr": "sum by (exporter) (otelcol_exporter_queue_size)",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"legendFormat": "queue {{exporter}}"
},
{
"refId": "B",
"expr": "sum by (exporter) (rate(otelcol_exporter_send_failed_spans[1m]))",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"legendFormat": "failed spans {{exporter}}"
},
{
"refId": "C",
"expr": "sum(rate(otelcol_processor_memory_limiter_refused_spans[1m]))",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"legendFormat": "refused (memory_limiter)"
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"custom": {
"lineWidth": 1,
"fillOpacity": 10
}
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom"
}
}
},
{
"id": 19,
"type": "row",
"title": "Логи и алерты",
"gridPos": {
"x": 0,
"y": 38,
"w": 24,
"h": 1
},
"collapsed": false,
"panels": []
},
{
"id": 20,
"type": "logs",
"title": "Структурные логи (API и worker), ошибки и предупреждения",
"datasource": {
"type": "loki",
"uid": "loki"
},
"gridPos": {
"x": 0,
"y": 39,
"w": 16,
"h": 10
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "loki",
"uid": "loki"
},
"expr": "{service_name=~\"messenger-.*\"} | detected_level=~\"warn|warning|error|ERROR|WARN\""
}
],
"options": {
"showTime": true,
"wrapLogMessage": true,
"enableLogDetails": true,
"sortOrder": "Descending"
}
},
{
"id": 21,
"type": "alertlist",
"title": "Алерты (firing / pending)",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 16,
"y": 39,
"w": 8,
"h": 10
},
"options": {
"alertInstanceLabelFilter": "",
"alertName": "",
"dashboardAlerts": false,
"groupBy": [],
"groupMode": "default",
"maxItems": 20,
"sortOrder": 1,
"stateFilter": {
"firing": true,
"pending": true,
"noData": true,
"normal": false,
"error": true
}
}
},
{
"id": 22,
"type": "traces",
"title": "Последние трассы API (Tempo)",
"datasource": {
"type": "tempo",
"uid": "tempo"
},
"gridPos": {
"x": 0,
"y": 49,
"w": 24,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "tempo",
"uid": "tempo"
},
"queryType": "traceql",
"query": "{ resource.service.name = \"messenger-api\" }",
"limit": 20
}
]
}
],
"annotations": {
"list": []
},
"templating": {
"list": []
}
}