Files
mtusi2026lab6-fork/infra/otel/grafana/dashboards/messenger.json
T
2026-11-14 05:00:23 +03:00

344 lines
8.4 KiB
JSON

{
"uid": "messenger-overview",
"title": "Messenger — наблюдаемость",
"schemaVersion": 39,
"version": 1,
"tags": [
"messenger",
"observability"
],
"timezone": "browser",
"refresh": "5s",
"time": {
"from": "now-15m",
"to": "now"
},
"panels": [
{
"id": 1,
"title": "API: запросы в секунду",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 0,
"w": 12,
"h": 9
},
"targets": [
{
"refId": "A",
"expr": "sum by (http_request_method, http_route) (rate(messenger_http_requests_total{http_route!~\"/health/.*\"}[1m]))",
"legendFormat": "{{http_request_method}} {{http_route}}"
}
],
"description": "",
"fieldConfig": {
"defaults": {
"unit": "reqps"
},
"overrides": []
},
"options": {}
},
{
"id": 2,
"title": "API: доля 5xx",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 0,
"w": 12,
"h": 9
},
"targets": [
{
"refId": "A",
"expr": "(sum(rate(messenger_http_requests_total{http_response_status_class=\"5xx\",http_route!~\"/health/.*\"}[1m])) or vector(0)) / clamp_min(sum(rate(messenger_http_requests_total{http_route!~\"/health/.*\"}[1m])), 0.000001)",
"legendFormat": "5xx / все бизнес-запросы"
}
],
"description": "Ошибки сервера: 5xx / все запросы, кроме health. 4xx не считаются отказом сервера.",
"fieldConfig": {
"defaults": {
"unit": "percentunit"
},
"overrides": []
},
"options": {}
},
{
"id": 3,
"title": "API: время ответа p50/p95/p99",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 9,
"w": 12,
"h": 9
},
"targets": [
{
"refId": "A",
"expr": "histogram_quantile(0.5, sum by (le) (rate(messenger_http_duration_seconds_bucket{http_route!~\"/health/.*\"}[1m])))",
"legendFormat": "p50"
},
{
"refId": "B",
"expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_http_duration_seconds_bucket{http_route!~\"/health/.*\"}[1m])))",
"legendFormat": "p95"
},
{
"refId": "C",
"expr": "histogram_quantile(0.99, sum by (le) (rate(messenger_http_duration_seconds_bucket{http_route!~\"/health/.*\"}[1m])))",
"legendFormat": "p99"
}
],
"description": "Histogram в секундах, buckets суммируются по репликам.",
"fieldConfig": {
"defaults": {
"unit": "s"
},
"overrides": []
},
"options": {}
},
{
"id": 4,
"title": "Worker: попытки в секунду по исходу",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 9,
"w": 12,
"h": 9
},
"targets": [
{
"refId": "A",
"expr": "sum by (outcome) (rate(messenger_job_attempts_total[1m]))",
"legendFormat": "{{outcome}}"
}
],
"description": "success — результат записан; error — попытка не удалась; deferred — истёк lease. Дубли без обработки не считаются.",
"fieldConfig": {
"defaults": {
"unit": "ops"
},
"overrides": []
},
"options": {}
},
{
"id": 5,
"title": "Worker: время обработки p95",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 18,
"w": 12,
"h": 9
},
"targets": [
{
"refId": "A",
"expr": "histogram_quantile(0.95, sum by (le, outcome) (rate(messenger_job_duration_seconds_bucket[1m])))",
"legendFormat": "{{outcome}}"
}
],
"description": "Одна фактическая попытка, включая S3, преобразования и фиксацию metadata.",
"fieldConfig": {
"defaults": {
"unit": "s"
},
"overrides": []
},
"options": {}
},
{
"id": 6,
"title": "Worker: обработанные попытки",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 18,
"w": 12,
"h": 9
},
"targets": [
{
"refId": "A",
"expr": "sum by (outcome) (messenger_job_attempts_total)",
"legendFormat": "{{outcome}}"
}
],
"description": "",
"fieldConfig": {
"defaults": {
"unit": "short"
},
"overrides": []
},
"options": {}
},
{
"id": 7,
"title": "API: структурные логи",
"type": "logs",
"datasource": {
"type": "loki",
"uid": "loki"
},
"gridPos": {
"x": 0,
"y": 27,
"w": 12,
"h": 9
},
"targets": [
{
"refId": "A",
"expr": "{service_name=\"messenger-api\"} | json",
"queryType": "range"
}
],
"description": "",
"fieldConfig": {
"defaults": {
"unit": "short"
},
"overrides": []
},
"options": {}
},
{
"id": 8,
"title": "Worker: структурные логи",
"type": "logs",
"datasource": {
"type": "loki",
"uid": "loki"
},
"gridPos": {
"x": 12,
"y": 27,
"w": 12,
"h": 9
},
"targets": [
{
"refId": "A",
"expr": "{service_name=\"messenger-worker\"} | json",
"queryType": "range"
}
],
"description": "",
"fieldConfig": {
"defaults": {
"unit": "short"
},
"overrides": []
},
"options": {}
},
{
"id": 9,
"title": "Реальные server/consumer traces",
"type": "table",
"datasource": {
"type": "tempo",
"uid": "tempo"
},
"gridPos": {
"x": 0,
"y": 36,
"w": 12,
"h": 9
},
"targets": [
{
"refId": "A",
"queryType": "traceqlSearch",
"query": "{ resource.service.name =~ \"messenger-api|messenger-worker\" }",
"limit": 20
}
],
"description": "Открыть trace в Explore; ссылка TraceID из строки Loki ведёт к той же трассе.",
"fieldConfig": {
"defaults": {
"unit": "short"
},
"overrides": []
},
"options": {}
},
{
"id": 10,
"title": "API: число 5xx бизнес-запросов",
"type": "stat",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 36,
"w": 12,
"h": 9
},
"targets": [
{
"refId": "A",
"expr": "sum(messenger_http_requests_total{http_response_status_class=\"5xx\",http_route!~\"/health/.*\"}) or vector(0)",
"instant": true
}
],
"fieldConfig": {
"defaults": {
"unit": "short"
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
}
},
"description": "Накопленное число 5xx: показывает и первую ошибку нового ряда, когда rate ещё не имеет двух разных точек."
}
],
"annotations": {
"list": []
},
"templating": {
"list": []
}
}