Files
mtusi2026lab6-fork/infra/otel/grafana/dashboards/messenger.json
T
2026-11-19 19:24:45 +03:00

811 lines
22 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.
{
"uid": "messenger-lab6",
"title": "Lab 6 · Messenger",
"description": "OpenTelemetry API и очереди изображений",
"tags": [
"messenger",
"opentelemetry"
],
"schemaVersion": 39,
"refresh": "5s",
"time": {
"from": "now-15m",
"to": "now"
},
"timezone": "browser",
"panels": [
{
"id": 1,
"title": "Запросы API",
"description": "Интенсивность по двум API-репликам. Readiness и liveness выключены на этапе инструментации.",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
},
"gridPos": {
"x": 0,
"y": 0,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "reqps"
},
"overrides": []
},
"targets": [
{
"refId": "A",
"expr": "sum(rate(messenger_http_requests_total{route!=\"unmatched\"}[30s]))",
"legendFormat": "известные маршруты",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
},
{
"refId": "B",
"expr": "sum(rate(messenger_http_requests_total{route!=\"unmatched\",status_class=\"5xx\"}[30s]))",
"legendFormat": "5xx",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
}
]
},
{
"id": 2,
"title": "Ошибки API",
"description": "5xx из приложения на известных маршрутах. 4xx входят в знаменатель.",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
},
"gridPos": {
"x": 12,
"y": 0,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "percentunit"
},
"overrides": []
},
"targets": [
{
"refId": "A",
"expr": "(sum(rate(messenger_http_requests_total{route!=\"unmatched\",status_class=\"5xx\"}[30s])) / sum(rate(messenger_http_requests_total{route!=\"unmatched\"}[30s])))",
"legendFormat": "5xx / все",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
},
{
"refId": "B",
"expr": "vector(0.01)",
"legendFormat": "допустимая доля",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
}
]
},
{
"id": 3,
"title": "Задержка API",
"description": "Перцентили из общих bucket всех реплик. Первая минута и низкий трафик дают шумную оценку.",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
},
"gridPos": {
"x": 0,
"y": 8,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "s"
},
"overrides": []
},
"targets": [
{
"refId": "A",
"expr": "histogram_quantile(0.50, sum by (le) (rate(messenger_http_duration_seconds_bucket[1m])))",
"legendFormat": "p50",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
},
{
"refId": "B",
"expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_http_duration_seconds_bucket[1m])))",
"legendFormat": "p95",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
},
{
"refId": "C",
"expr": "histogram_quantile(0.99, sum by (le) (rate(messenger_http_duration_seconds_bucket[1m])))",
"legendFormat": "p99",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
}
]
},
{
"id": 4,
"title": "Попытки worker",
"description": "Считаются обработанные попытки по исходу. Повторная попытка учитывается отдельно.",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
},
"gridPos": {
"x": 12,
"y": 8,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "ops"
},
"overrides": []
},
"targets": [
{
"refId": "A",
"expr": "sum by (outcome) (rate(messenger_job_attempts_total[30s]))",
"legendFormat": "{{outcome}}",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
}
]
},
{
"id": 5,
"title": "Задержка попытки worker",
"description": "От захвата lease до записи итога попытки или решения о повторе.",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
},
"gridPos": {
"x": 0,
"y": 16,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "s"
},
"overrides": []
},
"targets": [
{
"refId": "A",
"expr": "histogram_quantile(0.50, sum by (le) (rate(messenger_job_duration_seconds_bucket[1m])))",
"legendFormat": "p50",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
},
{
"refId": "B",
"expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_job_duration_seconds_bucket[1m])))",
"legendFormat": "p95",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
},
{
"refId": "C",
"expr": "histogram_quantile(0.99, sum by (le) (rate(messenger_job_duration_seconds_bucket[1m])))",
"legendFormat": "p99",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
}
]
},
{
"id": 6,
"title": "Время до ready",
"description": "SQL-время от принятия загрузки до записи ready. Гистограмма включает завершившиеся первые публикации.",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
},
"gridPos": {
"x": 12,
"y": 16,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "s"
},
"overrides": []
},
"targets": [
{
"refId": "A",
"expr": "histogram_quantile(0.50, sum by (le) (rate(messenger_attachment_time_to_ready_seconds_bucket[1m])))",
"legendFormat": "p50",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
},
{
"refId": "B",
"expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_attachment_time_to_ready_seconds_bucket[1m])))",
"legendFormat": "p95",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
},
{
"refId": "C",
"expr": "histogram_quantile(0.99, sum by (le) (rate(messenger_attachment_time_to_ready_seconds_bucket[1m])))",
"legendFormat": "p99",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
}
]
},
{
"id": 7,
"title": "Глубина очереди",
"description": "Строки outbox в queued, в том числе ожидающие XADD и backoff.",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
},
"gridPos": {
"x": 0,
"y": 24,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "short"
},
"overrides": []
},
"targets": [
{
"refId": "A",
"expr": "messenger_queue_depth",
"legendFormat": "queued",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
}
]
},
{
"id": 8,
"title": "Возраст старейшего задания",
"description": "Возраст от создания самой старой строки outbox в queued.",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
},
"gridPos": {
"x": 12,
"y": 24,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "s"
},
"overrides": []
},
"targets": [
{
"refId": "A",
"expr": "messenger_queue_oldest_age_seconds",
"legendFormat": "oldest",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
},
{
"refId": "B",
"expr": "vector(5)",
"legendFormat": "порог",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
}
]
},
{
"id": 9,
"title": "Соединения PostgreSQL",
"description": "В процессе Acquire учитываются и короткие вызовы. Смотрите динамику при устойчивом ожидании.",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
},
"gridPos": {
"x": 0,
"y": 32,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "short"
},
"overrides": []
},
"targets": [
{
"refId": "A",
"expr": "messenger_db_pool_used",
"legendFormat": "{{job}} {{instance}} / занято",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
},
{
"refId": "B",
"expr": "messenger_db_pool_capacity",
"legendFormat": "{{job}} {{instance}} / лимит",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
},
{
"refId": "C",
"expr": "messenger_db_pool_acquiring",
"legendFormat": "{{job}} {{instance}} / получение",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
}
]
},
{
"id": 10,
"title": "Получение соединения при пустом пуле",
"description": "Производная EmptyAcquireCount pgxpool. Включает ожидание создания соединения.",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
},
"gridPos": {
"x": 12,
"y": 32,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "ops"
},
"overrides": []
},
"targets": [
{
"refId": "A",
"expr": "rate(messenger_db_pool_waits_total[30s])",
"legendFormat": "{{job}} {{instance}}",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
}
]
},
{
"id": 11,
"title": "Занятые слоты worker",
"description": "Только свежие показания. Снимки с шагом 2 с могут пропускать очень короткие задания.",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
},
"gridPos": {
"x": 0,
"y": 40,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "percentunit"
},
"overrides": []
},
"targets": [
{
"refId": "A",
"expr": "sum(messenger_worker_busy and (time() - timestamp(messenger_worker_busy) < 8)) / sum(messenger_worker_capacity and (time() - timestamp(messenger_worker_capacity) < 8))",
"legendFormat": "busy / capacity",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
},
{
"refId": "B",
"expr": "avg_over_time((sum(messenger_worker_busy and (time() - timestamp(messenger_worker_busy) < 8)) / sum(messenger_worker_capacity and (time() - timestamp(messenger_worker_capacity) < 8)))[30s:2s])",
"legendFormat": "среднее за 30 с",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
}
]
},
{
"id": 12,
"title": "CPU контейнеров приложения",
"description": "CPU-seconds / wall-second по cgroup v2, включая дочерний Pillow в worker.",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
},
"gridPos": {
"x": 12,
"y": 40,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "cores"
},
"overrides": []
},
"targets": [
{
"refId": "A",
"expr": "rate(messenger_container_cpu_seconds_total[30s])",
"legendFormat": "{{job}} {{instance}}",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
}
]
},
{
"id": 13,
"title": "RAM контейнеров приложения",
"description": "Текущий memory.current cgroup v2.",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
},
"gridPos": {
"x": 0,
"y": 48,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "bytes"
},
"overrides": []
},
"targets": [
{
"refId": "A",
"expr": "messenger_container_memory_bytes",
"legendFormat": "{{job}} {{instance}}",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
}
]
},
{
"id": 14,
"title": "SLI за 30 минут",
"description": "Каждый upload попадает в когорту по истечении 5 с. Без трафика SLI отсутствует.",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
},
"gridPos": {
"x": 12,
"y": 48,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "percentunit"
},
"overrides": []
},
"targets": [
{
"refId": "A",
"expr": "1 - (sum(rate(messenger_http_requests_total{route!=\"unmatched\",status_class=\"5xx\"}[30m])) / sum(rate(messenger_http_requests_total{route!=\"unmatched\"}[30m])))",
"legendFormat": "API",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
},
{
"refId": "B",
"expr": "1 - (sum(rate(messenger_attachment_slo_jobs_total{outcome=\"missed\"}[30m])) / sum(rate(messenger_attachment_slo_jobs_total[30m])))",
"legendFormat": "ready ≤ 5 с",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
},
{
"refId": "C",
"expr": "vector(0.99)",
"legendFormat": "цель",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
}
]
},
{
"id": 15,
"title": "Burn rate",
"description": "Burn rate 1 соответствует расходу бюджета с нормативной скоростью.",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
},
"gridPos": {
"x": 0,
"y": 56,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "short"
},
"overrides": []
},
"targets": [
{
"refId": "A",
"expr": "(sum(rate(messenger_http_requests_total{route!=\"unmatched\",status_class=\"5xx\"}[10s])) / sum(rate(messenger_http_requests_total{route!=\"unmatched\"}[10s]))) / 0.01",
"legendFormat": "API 10s",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
},
{
"refId": "B",
"expr": "(sum(rate(messenger_http_requests_total{route!=\"unmatched\",status_class=\"5xx\"}[30s])) / sum(rate(messenger_http_requests_total{route!=\"unmatched\"}[30s]))) / 0.01",
"legendFormat": "API 30s",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
},
{
"refId": "C",
"expr": "(sum(rate(messenger_http_requests_total{route!=\"unmatched\",status_class=\"5xx\"}[25s])) / sum(rate(messenger_http_requests_total{route!=\"unmatched\"}[25s]))) / 0.01",
"legendFormat": "API 25s",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
},
{
"refId": "D",
"expr": "(sum(rate(messenger_http_requests_total{route!=\"unmatched\",status_class=\"5xx\"}[75s])) / sum(rate(messenger_http_requests_total{route!=\"unmatched\"}[75s]))) / 0.01",
"legendFormat": "API 75s",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
},
{
"refId": "E",
"expr": "(sum(rate(messenger_attachment_slo_jobs_total{outcome=\"missed\"}[10s])) / sum(rate(messenger_attachment_slo_jobs_total[10s]))) / 0.01",
"legendFormat": "Ready 10s",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
},
{
"refId": "F",
"expr": "(sum(rate(messenger_attachment_slo_jobs_total{outcome=\"missed\"}[30s])) / sum(rate(messenger_attachment_slo_jobs_total[30s]))) / 0.01",
"legendFormat": "Ready 30s",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
},
{
"refId": "G",
"expr": "(sum(rate(messenger_attachment_slo_jobs_total{outcome=\"missed\"}[25s])) / sum(rate(messenger_attachment_slo_jobs_total[25s]))) / 0.01",
"legendFormat": "Ready 25s",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
},
{
"refId": "H",
"expr": "(sum(rate(messenger_attachment_slo_jobs_total{outcome=\"missed\"}[75s])) / sum(rate(messenger_attachment_slo_jobs_total[75s]))) / 0.01",
"legendFormat": "Ready 75s",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
}
]
},
{
"id": 16,
"title": "Alerts в Prometheus",
"description": "Локальная история pending и firing за выбранный период.",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
},
"gridPos": {
"x": 12,
"y": 56,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "short"
},
"overrides": []
},
"targets": [
{
"refId": "A",
"expr": "ALERTS{alertname=~\"APIFastBurn|APISlowBurn|ReadyFastBurn|ReadySlowBurn|QueueLagHigh\"}",
"legendFormat": "{{alertname}} / {{alertstate}}",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
}
]
},
{
"id": 17,
"title": "Потери Collector",
"description": "Число элементов в терминально неотправленных или не поставленных в очередь батчах за минуту.",
"type": "timeseries",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
},
"gridPos": {
"x": 0,
"y": 64,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "short"
},
"overrides": []
},
"targets": [
{
"refId": "A",
"expr": "sum by (exporter) (increase({__name__=~\"otelcol_exporter_send_failed_(spans|log_records|metric_points)(_total)?\"}[1m]))",
"legendFormat": "{{exporter}} / send failed",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
},
{
"refId": "B",
"expr": "sum by (exporter) (increase({__name__=~\"otelcol_exporter_enqueue_failed_(spans|log_records|metric_points)(_total)?\"}[1m]))",
"legendFormat": "{{exporter}} / enqueue failed",
"datasource": {
"type": "prometheus",
"uid": "lab-prom"
}
}
]
},
{
"id": 18,
"title": "Логи API и worker",
"description": "В деталях записи есть trace_id и span_id. Ссылка Trace открывает Tempo.",
"type": "logs",
"datasource": {
"type": "loki",
"uid": "lab-loki"
},
"gridPos": {
"x": 12,
"y": 64,
"w": 12,
"h": 8
},
"fieldConfig": {
"defaults": {
"unit": "none"
},
"overrides": []
},
"targets": [
{
"refId": "A",
"expr": "{service_name=~\"messenger-api|messenger-worker\"}",
"legendFormat": "",
"datasource": {
"type": "loki",
"uid": "lab-loki"
}
}
]
}
]
}