189 lines
9.7 KiB
JSON
189 lines
9.7 KiB
JSON
{
|
|
"uid": "messenger-overview",
|
|
"title": "Messenger — observability level 4",
|
|
"description": "API, worker, queue, saturation. PromQL ссылается на реальные имена метрик, экспортированные SDK.",
|
|
"tags": ["messenger", "lab6"],
|
|
"timezone": "utc",
|
|
"editable": true,
|
|
"time": { "from": "now-30m", "to": "now" },
|
|
"refresh": "10s",
|
|
"panels": [
|
|
{
|
|
"type": "row",
|
|
"title": "HTTP API",
|
|
"gridPos": { "h": 1, "w": 24, "x": 0, "y": 0 },
|
|
"collapsed": false
|
|
},
|
|
{
|
|
"type": "timeseries",
|
|
"title": "HTTP RPS (by method, all replicas)",
|
|
"description": "Сумма rate по всем репликам. Метрика: http_server_request_duration_seconds_count.",
|
|
"datasource": { "uid": "prometheus", "type": "prometheus" },
|
|
"gridPos": { "h": 8, "w": 8, "x": 0, "y": 1 },
|
|
"targets": [
|
|
{
|
|
"expr": "sum by (http_request_method) (rate(http_server_request_duration_seconds_count{service_name=\"messenger-api\"}[$__rate_interval]))",
|
|
"legendFormat": "{{http_request_method}}"
|
|
}
|
|
],
|
|
"fieldConfig": {
|
|
"defaults": { "unit": "reqps", "custom": { "lineWidth": 2, "fillOpacity": 15 } }
|
|
}
|
|
},
|
|
{
|
|
"type": "timeseries",
|
|
"title": "HTTP 5xx error ratio",
|
|
"description": "SLI: 5xx / все запросы. Health GET не даёт 5xx при живой БД и не искажает знаменатель.",
|
|
"datasource": { "uid": "prometheus", "type": "prometheus" },
|
|
"gridPos": { "h": 8, "w": 8, "x": 8, "y": 1 },
|
|
"targets": [
|
|
{
|
|
"expr": "sum(rate(http_server_request_duration_seconds_count{service_name=\"messenger-api\",http_response_status_code=~\"5..\"}[$__rate_interval])) / sum(rate(http_server_request_duration_seconds_count{service_name=\"messenger-api\"}[$__rate_interval]))",
|
|
"legendFormat": "5xx ratio"
|
|
}
|
|
],
|
|
"fieldConfig": {
|
|
"defaults": { "unit": "percentunit", "max": 1, "custom": { "lineWidth": 2 } },
|
|
"overrides": [
|
|
{ "matcher": { "id": "byName", "options": "5xx ratio" },
|
|
"properties": [{ "id": "color", "value": { "mode": "fixed", "fixedColor": "red" } }] }
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"type": "timeseries",
|
|
"title": "HTTP latency p50 / p95 / p99",
|
|
"description": "Глобальные percentiles из суммы histogram buckets всех реплик. Среднее p99 реплик НЕ вычисляется.",
|
|
"datasource": { "uid": "prometheus", "type": "prometheus" },
|
|
"gridPos": { "h": 8, "w": 8, "x": 16, "y": 1 },
|
|
"targets": [
|
|
{ "expr": "histogram_quantile(0.50, sum by (le) (rate(http_server_request_duration_seconds_bucket{service_name=\"messenger-api\"}[$__rate_interval])))", "legendFormat": "p50" },
|
|
{ "expr": "histogram_quantile(0.95, sum by (le) (rate(http_server_request_duration_seconds_bucket{service_name=\"messenger-api\"}[$__rate_interval])))", "legendFormat": "p95" },
|
|
{ "expr": "histogram_quantile(0.99, sum by (le) (rate(http_server_request_duration_seconds_bucket{service_name=\"messenger-api\"}[$__rate_interval])))", "legendFormat": "p99" }
|
|
],
|
|
"fieldConfig": { "defaults": { "unit": "s" } }
|
|
},
|
|
{
|
|
"type": "row",
|
|
"title": "Worker & Jobs",
|
|
"gridPos": { "h": 1, "w": 24, "x": 0, "y": 9 },
|
|
"collapsed": false
|
|
},
|
|
{
|
|
"type": "timeseries",
|
|
"title": "Jobs processed rate (by outcome)",
|
|
"description": "Успехи, retries, терминальные отказы. Метрика: messenger_jobs_processed_total.",
|
|
"datasource": { "uid": "prometheus", "type": "prometheus" },
|
|
"gridPos": { "h": 8, "w": 8, "x": 0, "y": 10 },
|
|
"targets": [
|
|
{
|
|
"expr": "sum by (outcome) (rate(messenger_jobs_processed_total{service_name=\"messenger-worker\"}[$__rate_interval]))",
|
|
"legendFormat": "{{outcome}}"
|
|
}
|
|
],
|
|
"fieldConfig": { "defaults": { "unit": "ops" } }
|
|
},
|
|
{
|
|
"type": "timeseries",
|
|
"title": "Job processing duration p50 / p95 / p99",
|
|
"description": "Время в worker.process (staging -> variants -> original -> COMMIT). Метрика: messenger_job_duration_seconds.",
|
|
"datasource": { "uid": "prometheus", "type": "prometheus" },
|
|
"gridPos": { "h": 8, "w": 8, "x": 8, "y": 10 },
|
|
"targets": [
|
|
{ "expr": "histogram_quantile(0.50, sum by (le) (rate(messenger_job_duration_seconds_bucket{service_name=\"messenger-worker\"}[$__rate_interval])))", "legendFormat": "p50" },
|
|
{ "expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_job_duration_seconds_bucket{service_name=\"messenger-worker\"}[$__rate_interval])))", "legendFormat": "p95" },
|
|
{ "expr": "histogram_quantile(0.99, sum by (le) (rate(messenger_job_duration_seconds_bucket{service_name=\"messenger-worker\"}[$__rate_interval])))", "legendFormat": "p99" }
|
|
],
|
|
"fieldConfig": { "defaults": { "unit": "s" } }
|
|
},
|
|
{
|
|
"type": "timeseries",
|
|
"title": "End-to-end time to ready p50 / p95 / p99",
|
|
"description": "От durable acceptance (202) до ready. SLI. Метрика: messenger_time_to_ready_seconds.",
|
|
"datasource": { "uid": "prometheus", "type": "prometheus" },
|
|
"gridPos": { "h": 8, "w": 8, "x": 16, "y": 10 },
|
|
"targets": [
|
|
{ "expr": "histogram_quantile(0.50, sum by (le) (rate(messenger_time_to_ready_seconds_bucket[$__rate_interval])))", "legendFormat": "p50" },
|
|
{ "expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_time_to_ready_seconds_bucket[$__rate_interval])))", "legendFormat": "p95" },
|
|
{ "expr": "histogram_quantile(0.99, sum by (le) (rate(messenger_time_to_ready_seconds_bucket[$__rate_interval])))", "legendFormat": "p99" }
|
|
],
|
|
"fieldConfig": { "defaults": { "unit": "s" } }
|
|
},
|
|
{
|
|
"type": "row",
|
|
"title": "Queue & Backlog",
|
|
"gridPos": { "h": 1, "w": 24, "x": 0, "y": 18 },
|
|
"collapsed": false
|
|
},
|
|
{
|
|
"type": "timeseries",
|
|
"title": "Queue depth (broker stream + DB jobs queued)",
|
|
"description": "Broker = Redis Streams PEL (pending не-acked). DB = jobs.status='queued'. Источники: messenger_queue_depth, messenger_jobs_queued.",
|
|
"datasource": { "uid": "prometheus", "type": "prometheus" },
|
|
"gridPos": { "h": 8, "w": 12, "x": 0, "y": 19 },
|
|
"targets": [
|
|
{ "expr": "sum(messenger_queue_depth{service_name=\"messenger-api\"})", "legendFormat": "broker pending" },
|
|
{ "expr": "sum(messenger_jobs_queued{service_name=\"messenger-api\"})", "legendFormat": "DB queued jobs" }
|
|
],
|
|
"fieldConfig": { "defaults": { "unit": "short" } }
|
|
},
|
|
{
|
|
"type": "timeseries",
|
|
"title": "Queue oldest age (broker + DB)",
|
|
"description": "Сколько секунд старейшее сообщение/задание ещё не обработано. Рост = worker не справляется или недоступен.",
|
|
"datasource": { "uid": "prometheus", "type": "prometheus" },
|
|
"gridPos": { "h": 8, "w": 12, "x": 12, "y": 19 },
|
|
"targets": [
|
|
{ "expr": "max(messenger_queue_oldest_age_seconds{service_name=\"messenger-api\"})", "legendFormat": "broker oldest (s)" },
|
|
{ "expr": "max(messenger_jobs_oldest_queued_age_seconds{service_name=\"messenger-api\"})", "legendFormat": "DB oldest (s)" }
|
|
],
|
|
"fieldConfig": { "defaults": { "unit": "s" } }
|
|
},
|
|
{
|
|
"type": "row",
|
|
"title": "Saturation",
|
|
"gridPos": { "h": 1, "w": 24, "x": 0, "y": 27 },
|
|
"collapsed": false
|
|
},
|
|
{
|
|
"type": "timeseries",
|
|
"title": "DB pool used / capacity",
|
|
"description": "Acquired connections из pgx pool. Метрики: messenger_db_pool_used, messenger_db_pool_capacity.",
|
|
"datasource": { "uid": "prometheus", "type": "prometheus" },
|
|
"gridPos": { "h": 8, "w": 8, "x": 0, "y": 28 },
|
|
"targets": [
|
|
{ "expr": "sum(messenger_db_pool_used{service_name=\"messenger-api\"})", "legendFormat": "used (api)" },
|
|
{ "expr": "sum(messenger_db_pool_capacity{service_name=\"messenger-api\"})", "legendFormat": "capacity (api)" },
|
|
{ "expr": "sum(messenger_db_pool_used{service_name=\"messenger-worker\"})", "legendFormat": "used (worker)" },
|
|
{ "expr": "sum(messenger_db_pool_capacity{service_name=\"messenger-worker\"})", "legendFormat": "capacity (worker)" }
|
|
],
|
|
"fieldConfig": { "defaults": { "unit": "short" } }
|
|
},
|
|
{
|
|
"type": "timeseries",
|
|
"title": "Worker saturation (busy / capacity)",
|
|
"description": "1 = worker занят, 0 = простаивает. Для одного worker это occupancy rate.",
|
|
"datasource": { "uid": "prometheus", "type": "prometheus" },
|
|
"gridPos": { "h": 8, "w": 8, "x": 8, "y": 28 },
|
|
"targets": [
|
|
{ "expr": "sum(messenger_worker_busy{service_name=\"messenger-worker\"})", "legendFormat": "busy" },
|
|
{ "expr": "sum(messenger_worker_capacity{service_name=\"messenger-worker\"})", "legendFormat": "capacity" }
|
|
],
|
|
"fieldConfig": { "defaults": { "unit": "short" } }
|
|
},
|
|
{
|
|
"type": "timeseries",
|
|
"title": "DB pool empty-acquire events",
|
|
"description": "Счётчик случаев, когда acquire ждал свободного соединения. Рост = пул undersized. Метрика: messenger_db_pool_empty_acquires_total.",
|
|
"datasource": { "uid": "prometheus", "type": "prometheus" },
|
|
"gridPos": { "h": 8, "w": 8, "x": 16, "y": 28 },
|
|
"targets": [
|
|
{
|
|
"expr": "sum by (service_name) (rate(messenger_db_pool_empty_acquires_total[$__rate_interval]))",
|
|
"legendFormat": "{{service_name}}"
|
|
}
|
|
],
|
|
"fieldConfig": { "defaults": { "unit": "ops" } }
|
|
}
|
|
]
|
|
} |