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

213 lines
13 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"annotations": {"list": []},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 1,
"links": [],
"refresh": "10s",
"schemaVersion": 39,
"tags": ["messenger", "lab6"],
"time": {"from": "now-1h", "to": "now"},
"timezone": "browser",
"title": "Messenger observability",
"uid": "messenger-lab6",
"version": 1,
"panels": [
{
"type": "text",
"id": 1,
"title": "SLI и единицы",
"gridPos": {"h": 5, "w": 24, "x": 0, "y": 0},
"options": {
"mode": "markdown",
"content": "**API availability.** SLI = бизнес-ответы 5xx / все бизнес-запросы, без `/health`. SLO = 99% успеха на окне 5 минут. Алерт смотрит окно 1 минута и порог 5%.\n\n**Time to ready.** SLI = гистограмма секунд от записи вложения до `ready`. SLO = p95 не выше 60 с. Алерт смотрит возраст старейшей queued/processing задачи и порог 30 с. Это backlog, не среднее время обработки.\n\nПроцентили считаются `histogram_quantile` по сумме bucket всех реплик (`sum by (le)`), а не как среднее готовых p95. Единицы: RPS — запросы/с, длительность и возраст — секунды, пул и worker — штуки, память — байты, CPU — ядра."
}
},
{
"type": "timeseries",
"id": 2,
"title": "API RPS",
"description": "Запросы в секунду, только sli=business. Единица req/s.",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"gridPos": {"h": 8, "w": 8, "x": 0, "y": 5},
"fieldConfig": {"defaults": {"unit": "reqps", "custom": {"drawStyle": "line", "fillOpacity": 15}}, "overrides": []},
"options": {"legend": {"displayMode": "list", "placement": "bottom"}},
"targets": [
{
"refId": "A",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"expr": "sum by (status_class) (rate(http_server_requests_total{service_name=\"messenger-api\",sli=\"business\"}[1m]))",
"legendFormat": "{{status_class}}"
}
]
},
{
"type": "timeseries",
"id": 3,
"title": "Ошибки API",
"description": "Сколько бизнес-ответов 4xx и 5xx накоплено. 4xx — ошибка запроса, 5xx — сбой сервера. Алерт и SLO по-прежнему только про 5xx.",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"gridPos": {"h": 8, "w": 8, "x": 8, "y": 5},
"fieldConfig": {"defaults": {"unit": "short", "min": 0, "custom": {"drawStyle": "line", "fillOpacity": 10}}, "overrides": []},
"options": {"legend": {"displayMode": "list", "placement": "bottom"}},
"targets": [
{
"refId": "A",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"expr": "sum by (status_class) (http_server_requests_total{service_name=\"messenger-api\",sli=\"business\",status_class=~\"4xx|5xx\"}) or label_replace(vector(0), \"status_class\", \"4xx\", \"\", \"\") or label_replace(vector(0), \"status_class\", \"5xx\", \"\", \"\")",
"legendFormat": "{{status_class}}"
}
]
},
{
"type": "timeseries",
"id": 4,
"title": "API duration",
"description": "Секунды. histogram_quantile от суммы bucket всех реплик API.",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"gridPos": {"h": 8, "w": 8, "x": 16, "y": 5},
"fieldConfig": {"defaults": {"unit": "s", "custom": {"drawStyle": "line", "fillOpacity": 10}}, "overrides": []},
"options": {"legend": {"displayMode": "list", "placement": "bottom"}},
"targets": [
{"refId": "A", "datasource": {"type": "prometheus", "uid": "prometheus"}, "expr": "histogram_quantile(0.50, sum by (le) (rate(http_server_duration_seconds_bucket{service_name=\"messenger-api\",sli=\"business\"}[5m])))", "legendFormat": "p50"},
{"refId": "B", "datasource": {"type": "prometheus", "uid": "prometheus"}, "expr": "histogram_quantile(0.95, sum by (le) (rate(http_server_duration_seconds_bucket{service_name=\"messenger-api\",sli=\"business\"}[5m])))", "legendFormat": "p95"},
{"refId": "C", "datasource": {"type": "prometheus", "uid": "prometheus"}, "expr": "histogram_quantile(0.99, sum by (le) (rate(http_server_duration_seconds_bucket{service_name=\"messenger-api\",sli=\"business\"}[5m])))", "legendFormat": "p99"}
]
},
{
"type": "timeseries",
"id": 5,
"title": "Jobs",
"description": "Задачи в секунду по outcome. Единица jobs/s.",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"gridPos": {"h": 8, "w": 8, "x": 0, "y": 13},
"fieldConfig": {"defaults": {"unit": "ops", "custom": {"drawStyle": "line", "fillOpacity": 15}}, "overrides": []},
"options": {"legend": {"displayMode": "list", "placement": "bottom"}},
"targets": [
{"refId": "A", "datasource": {"type": "prometheus", "uid": "prometheus"}, "expr": "sum by (outcome) (rate(jobs_processed_total{job_type=\"attachment.process.v1\",outcome=~\"ready|failed|retry\"}[5m]))", "legendFormat": "{{outcome}}"}
]
},
{
"type": "timeseries",
"id": 6,
"title": "Job duration",
"description": "Секунды обработки. p95 из гистограммы, отдельно для ready и failed.",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"gridPos": {"h": 8, "w": 8, "x": 8, "y": 13},
"fieldConfig": {"defaults": {"unit": "s", "custom": {"drawStyle": "line", "fillOpacity": 10}}, "overrides": []},
"options": {"legend": {"displayMode": "list", "placement": "bottom"}},
"targets": [
{"refId": "A", "datasource": {"type": "prometheus", "uid": "prometheus"}, "expr": "histogram_quantile(0.50, sum by (le) (rate(jobs_duration_seconds_bucket{outcome=~\"ready|failed|retry\"}[5m])))", "legendFormat": "p50"},
{"refId": "B", "datasource": {"type": "prometheus", "uid": "prometheus"}, "expr": "histogram_quantile(0.95, sum by (le) (rate(jobs_duration_seconds_bucket{outcome=~\"ready|failed|retry\"}[5m])))", "legendFormat": "p95"},
{"refId": "C", "datasource": {"type": "prometheus", "uid": "prometheus"}, "expr": "histogram_quantile(0.99, sum by (le) (rate(jobs_duration_seconds_bucket{outcome=~\"ready|failed|retry\"}[5m])))", "legendFormat": "p99"}
]
},
{
"type": "timeseries",
"id": 7,
"title": "Time to ready",
"description": "Секунды от принятия вложения до ready. p95 — SLO 60 с.",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"gridPos": {"h": 8, "w": 8, "x": 16, "y": 13},
"fieldConfig": {"defaults": {"unit": "s", "custom": {"drawStyle": "line", "fillOpacity": 10}}, "overrides": []},
"options": {"legend": {"displayMode": "list", "placement": "bottom"}},
"targets": [
{"refId": "A", "datasource": {"type": "prometheus", "uid": "prometheus"}, "expr": "histogram_quantile(0.50, sum by (le) (rate(attachment_time_to_ready_seconds_bucket[5m])))", "legendFormat": "p50"},
{"refId": "B", "datasource": {"type": "prometheus", "uid": "prometheus"}, "expr": "histogram_quantile(0.95, sum by (le) (rate(attachment_time_to_ready_seconds_bucket[5m])))", "legendFormat": "p95"},
{"refId": "C", "datasource": {"type": "prometheus", "uid": "prometheus"}, "expr": "histogram_quantile(0.99, sum by (le) (rate(attachment_time_to_ready_seconds_bucket[5m])))", "legendFormat": "p99"}
]
},
{
"type": "timeseries",
"id": 8,
"title": "Queue depth",
"description": "Число задач queued или processing. max, чтобы две реплики API не удваивали одно наблюдение.",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"gridPos": {"h": 8, "w": 8, "x": 0, "y": 21},
"fieldConfig": {"defaults": {"unit": "short", "custom": {"drawStyle": "line", "fillOpacity": 15}}, "overrides": []},
"options": {"legend": {"displayMode": "list", "placement": "bottom"}},
"targets": [
{"refId": "A", "datasource": {"type": "prometheus", "uid": "prometheus"}, "expr": "max(queue_depth_ratio{queue=\"attachment.jobs\"})", "legendFormat": "attachment.jobs"}
]
},
{
"type": "timeseries",
"id": 9,
"title": "Oldest job age",
"description": "Секунды. Порог алерта 30 с отмечен как backlog, не как latency worker.",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"gridPos": {"h": 8, "w": 8, "x": 8, "y": 21},
"fieldConfig": {"defaults": {"unit": "s", "custom": {"drawStyle": "line", "fillOpacity": 10}}, "overrides": []},
"options": {"legend": {"displayMode": "list", "placement": "bottom"}},
"targets": [
{"refId": "A", "datasource": {"type": "prometheus", "uid": "prometheus"}, "expr": "max(queue_oldest_age_seconds{queue=\"attachment.jobs\"})", "legendFormat": "oldest"}
]
},
{
"type": "timeseries",
"id": 10,
"title": "DB pool",
"description": "Соединения: used — занятые, waiting — ждущие checkout, capacity — размер пула с overflow. Сумма по репликам API.",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"gridPos": {"h": 8, "w": 8, "x": 16, "y": 21},
"fieldConfig": {"defaults": {"unit": "short", "custom": {"drawStyle": "line", "fillOpacity": 10}}, "overrides": []},
"options": {"legend": {"displayMode": "list", "placement": "bottom"}},
"targets": [
{"refId": "A", "datasource": {"type": "prometheus", "uid": "prometheus"}, "expr": "sum by (state) (db_pool_connections_ratio{service_name=\"messenger-api\"})", "legendFormat": "{{state}}"}
]
},
{
"type": "timeseries",
"id": 11,
"title": "Worker saturation",
"description": "busy — занятые слоты, capacity — WORKER_CONCURRENCY.",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"gridPos": {"h": 8, "w": 8, "x": 0, "y": 29},
"fieldConfig": {"defaults": {"unit": "short", "custom": {"drawStyle": "line", "fillOpacity": 10}}, "overrides": []},
"options": {"legend": {"displayMode": "list", "placement": "bottom"}},
"targets": [
{"refId": "A", "datasource": {"type": "prometheus", "uid": "prometheus"}, "expr": "max by (state) (worker_slots_ratio{service_name=\"messenger-worker\"})", "legendFormat": "{{state}}"}
]
},
{
"type": "timeseries",
"id": 12,
"title": "Process CPU",
"description": "Секунды CPU на секунду стены, сумма процессов сервиса. Единица — ядра.",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"gridPos": {"h": 8, "w": 8, "x": 8, "y": 29},
"fieldConfig": {"defaults": {"unit": "short", "custom": {"drawStyle": "line", "fillOpacity": 10}}, "overrides": []},
"options": {"legend": {"displayMode": "list", "placement": "bottom"}},
"targets": [
{"refId": "A", "datasource": {"type": "prometheus", "uid": "prometheus"}, "expr": "sum by (service_name) (process_cpu_utilization_ratio)", "legendFormat": "{{service_name}}"}
]
},
{
"type": "timeseries",
"id": 13,
"title": "Process memory",
"description": "RSS процессов, байты.",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"gridPos": {"h": 8, "w": 8, "x": 16, "y": 29},
"fieldConfig": {"defaults": {"unit": "bytes", "custom": {"drawStyle": "line", "fillOpacity": 10}}, "overrides": []},
"options": {"legend": {"displayMode": "list", "placement": "bottom"}},
"targets": [
{"refId": "A", "datasource": {"type": "prometheus", "uid": "prometheus"}, "expr": "sum by (service_name) (process_memory_usage_bytes)", "legendFormat": "{{service_name}}"}
]
},
{
"type": "timeseries",
"id": 14,
"title": "Prometheus alert state",
"description": "1 — firing. Пропавший ряд — resolved/inactive. Имена HighApiErrorRate и QueueLagHigh.",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"gridPos": {"h": 8, "w": 24, "x": 0, "y": 37},
"fieldConfig": {"defaults": {"unit": "short", "min": 0, "max": 1, "custom": {"drawStyle": "line", "fillOpacity": 10}}, "overrides": []},
"options": {"legend": {"displayMode": "list", "placement": "bottom"}},
"targets": [
{"refId": "A", "datasource": {"type": "prometheus", "uid": "prometheus"}, "expr": "ALERTS{alertname=~\"HighApiErrorRate|QueueLagHigh\"}", "legendFormat": "{{alertname}} {{alertstate}}"}
]
}
]
}