Files
mtusi2026lab2/infra/grafana/dashboards/messenger-api.json
T
Artyom 12db77133f Forward the lab 5 foundation while preserving lab 6 telemetry
Source: immutable lab5 snapshot f88e9ba43cdfd7eb6a5a7ae5feb4247b4e820071; forward the allowed diff from 64d5c67. Carry SQLAlchemy, Alembic, reliability fixes, versioned jobs, infrastructure and student tests without changing protected coursework files.

Validation: make check, validate, lint; 515 student tests passed with one Linux-only skip; public smoke with telemetry enabled and repeat migration passed. Stop the owned stack and retain volumes. Preserve the existing OTel work in progress; grade implementation remains a separate phase.
2026-11-06 12:29:35 +03:00

864 lines
22 KiB
JSON

{
"uid": "messenger-api",
"title": "Messenger · API RED",
"description": "RED по endpoint, SLI/SLO, логи и трассы API.",
"tags": [
"messenger",
"lab6",
"red"
],
"timezone": "browser",
"editable": false,
"graphTooltip": 1,
"refresh": "10s",
"schemaVersion": 41,
"version": 1,
"time": {
"from": "now-30m",
"to": "now"
},
"timepicker": {},
"fiscalYearStartMonth": 0,
"liveNow": false,
"links": [
{
"title": "Messenger",
"type": "dashboards",
"tags": [
"messenger"
],
"asDropdown": true,
"includeVars": false,
"keepTime": true
}
],
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"enable": true,
"iconColor": "red",
"name": "Firing alerts",
"expr": "ALERTS{alertstate=\"firing\"}",
"step": "15s",
"titleFormat": "{{alertname}}",
"textFormat": "{{alertname}} firing",
"useValueForTime": false
}
]
},
"templating": {
"list": [
{
"name": "route",
"label": "Маршрут",
"type": "query",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"query": {
"query": "label_values(http_server_request_duration_seconds_count{job=\"messenger-api\"}, http_route)",
"refId": "PrometheusVariableQueryEditor-VariableQuery",
"qryType": 1
},
"definition": "label_values(http_server_request_duration_seconds_count{job=\"messenger-api\"}, http_route)",
"refresh": 2,
"includeAll": true,
"multi": true,
"allValue": ".*",
"current": {
"selected": true,
"text": [
"All"
],
"value": [
"$__all"
]
},
"sort": 1
},
{
"name": "instance",
"label": "Реплика",
"type": "query",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"query": {
"query": "label_values(http_server_request_duration_seconds_count{job=\"messenger-api\"}, instance)",
"refId": "PrometheusVariableQueryEditor-VariableQuery",
"qryType": 1
},
"definition": "label_values(http_server_request_duration_seconds_count{job=\"messenger-api\"}, instance)",
"refresh": 2,
"includeAll": true,
"multi": true,
"allValue": ".*",
"current": {
"selected": true,
"text": [
"All"
],
"value": [
"$__all"
]
},
"sort": 1
}
]
},
"panels": [
{
"type": "stat",
"title": "RPS бизнес-запросов",
"description": "Все маршруты, кроме /health/*; сумма по репликам.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"refId": "A",
"expr": "sum(rate(http_server_request_duration_seconds_count{job=\"messenger-api\", http_route!~\"/health/.*\"}[$__rate_interval]))",
"legendFormat": "__auto",
"range": true,
"exemplar": false
}
],
"fieldConfig": {
"defaults": {
"unit": "reqps",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
}
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto"
},
"id": 1,
"gridPos": {
"x": 0,
"y": 0,
"w": 6,
"h": 4
}
},
{
"type": "stat",
"title": "Доля 5xx (2m)",
"description": "SLI доступности: 5xx / все бизнес-запросы без /health/*. Неверный пароль (401) не считается отказом.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"refId": "A",
"expr": "messenger:http_errors:ratio_rate2m",
"legendFormat": "__auto",
"range": true,
"exemplar": false
}
],
"fieldConfig": {
"defaults": {
"unit": "percentunit",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "orange",
"value": 0.01
},
{
"color": "red",
"value": 0.05
}
]
},
"decimals": 2
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto"
},
"id": 2,
"gridPos": {
"x": 6,
"y": 0,
"w": 6,
"h": 4
}
},
{
"type": "stat",
"title": "p95 latency (5m)",
"description": "histogram_quantile по сумме buckets всех реплик, не среднее p95.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"refId": "A",
"expr": "messenger:http_request_duration_seconds:p95_5m",
"legendFormat": "__auto",
"range": true,
"exemplar": false
}
],
"fieldConfig": {
"defaults": {
"unit": "s",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "orange",
"value": 0.3
},
{
"color": "red",
"value": 0.5
}
]
}
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto"
},
"id": 3,
"gridPos": {
"x": 12,
"y": 0,
"w": 6,
"h": 4
}
},
{
"type": "stat",
"title": "Доля не-5xx (окно 1h)",
"description": "Доля не-5xx бизнес-запросов за 1h; цель 99%.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"refId": "A",
"expr": "1 - messenger:http_errors:ratio_rate1h",
"legendFormat": "__auto",
"range": true,
"exemplar": false
}
],
"fieldConfig": {
"defaults": {
"unit": "percentunit",
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"decimals": 3
},
"overrides": []
},
"options": {
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"colorMode": "value",
"graphMode": "area",
"textMode": "auto"
},
"id": 4,
"gridPos": {
"x": 18,
"y": 0,
"w": 6,
"h": 4
}
},
{
"type": "row",
"title": "Rate / Errors / Duration по endpoint",
"collapsed": false,
"panels": [],
"id": 5,
"gridPos": {
"x": 0,
"y": 4,
"w": 24,
"h": 1
}
},
{
"type": "timeseries",
"title": "RPS по маршруту и классу статуса",
"description": "Recording rule messenger:http_requests:rate2m; status class выводится из http.response.status_code.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"refId": "A",
"expr": "sum by (http_route, http_request_method, status_class) (messenger:http_requests:rate2m{http_route=~\"$route\"})",
"legendFormat": "{{http_request_method}} {{http_route}} {{status_class}}",
"range": true,
"exemplar": false
}
],
"fieldConfig": {
"defaults": {
"unit": "reqps",
"custom": {
"drawStyle": "line",
"lineWidth": 1,
"fillOpacity": 10,
"showPoints": "never",
"spanNulls": false,
"stacking": {
"mode": "none",
"group": "A"
}
},
"min": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "table",
"placement": "bottom",
"calcs": [
"lastNotNull",
"max"
]
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"id": 6,
"gridPos": {
"x": 0,
"y": 5,
"w": 12,
"h": 8
}
},
{
"type": "timeseries",
"title": "Доля ошибок",
"description": "Числитель SLI — только 5xx; 4xx показаны отдельно и в SLO не входят.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"refId": "A",
"expr": "(sum(rate(http_server_request_duration_seconds_count{job=\"messenger-api\", http_route!~\"/health/.*\", http_route=~\"$route\", instance=~\"$instance\", http_response_status_code=~\"5..\"}[$__rate_interval])) or vector(0)) / sum(rate(http_server_request_duration_seconds_count{job=\"messenger-api\", http_route!~\"/health/.*\", http_route=~\"$route\", instance=~\"$instance\"}[$__rate_interval]))",
"legendFormat": "5xx / все (SLI)",
"range": true,
"exemplar": false
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"refId": "B",
"expr": "(sum(rate(http_server_request_duration_seconds_count{job=\"messenger-api\", http_route!~\"/health/.*\", http_route=~\"$route\", instance=~\"$instance\", http_response_status_code=~\"4..\"}[$__rate_interval])) or vector(0)) / sum(rate(http_server_request_duration_seconds_count{job=\"messenger-api\", http_route!~\"/health/.*\", http_route=~\"$route\", instance=~\"$instance\"}[$__rate_interval]))",
"legendFormat": "4xx / все (клиент)",
"range": true,
"exemplar": false
}
],
"fieldConfig": {
"defaults": {
"unit": "percentunit",
"custom": {
"drawStyle": "line",
"lineWidth": 1,
"fillOpacity": 10,
"showPoints": "never",
"spanNulls": false,
"stacking": {
"mode": "none",
"group": "A"
}
},
"min": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "table",
"placement": "bottom",
"calcs": [
"lastNotNull",
"max"
]
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"id": 7,
"gridPos": {
"x": 12,
"y": 5,
"w": 12,
"h": 8
}
},
{
"type": "timeseries",
"title": "Latency p50 / p95 / p99",
"description": "Из histogram buckets (секунды) всех выбранных реплик; exemplars ведут в Tempo.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"refId": "A",
"expr": "histogram_quantile(0.5, sum by (le) (rate(http_server_request_duration_seconds_bucket{job=\"messenger-api\", http_route!~\"/health/.*\", http_route=~\"$route\", instance=~\"$instance\"}[$__rate_interval])))",
"legendFormat": "p50",
"range": true,
"exemplar": true
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"refId": "B",
"expr": "histogram_quantile(0.95, sum by (le) (rate(http_server_request_duration_seconds_bucket{job=\"messenger-api\", http_route!~\"/health/.*\", http_route=~\"$route\", instance=~\"$instance\"}[$__rate_interval])))",
"legendFormat": "p95",
"range": true,
"exemplar": true
},
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"refId": "C",
"expr": "histogram_quantile(0.99, sum by (le) (rate(http_server_request_duration_seconds_bucket{job=\"messenger-api\", http_route!~\"/health/.*\", http_route=~\"$route\", instance=~\"$instance\"}[$__rate_interval])))",
"legendFormat": "p99",
"range": true,
"exemplar": true
}
],
"fieldConfig": {
"defaults": {
"unit": "s",
"custom": {
"drawStyle": "line",
"lineWidth": 1,
"fillOpacity": 10,
"showPoints": "never",
"spanNulls": false,
"stacking": {
"mode": "none",
"group": "A"
}
},
"min": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "table",
"placement": "bottom",
"calcs": [
"lastNotNull",
"max"
]
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"id": 8,
"gridPos": {
"x": 0,
"y": 13,
"w": 12,
"h": 8
}
},
{
"type": "timeseries",
"title": "p95 по маршруту",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"refId": "A",
"expr": "histogram_quantile(0.95, sum by (le, http_route) (rate(http_server_request_duration_seconds_bucket{job=\"messenger-api\", http_route!~\"/health/.*\", http_route=~\"$route\", instance=~\"$instance\"}[$__rate_interval])))",
"legendFormat": "{{http_route}}",
"range": true,
"exemplar": false
}
],
"fieldConfig": {
"defaults": {
"unit": "s",
"custom": {
"drawStyle": "line",
"lineWidth": 1,
"fillOpacity": 10,
"showPoints": "never",
"spanNulls": false,
"stacking": {
"mode": "none",
"group": "A"
}
},
"min": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "table",
"placement": "bottom",
"calcs": [
"lastNotNull",
"max"
]
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"id": 9,
"gridPos": {
"x": 12,
"y": 13,
"w": 12,
"h": 8
}
},
{
"type": "timeseries",
"title": "RPS по реплике",
"description": "instance = service.instance.id (реплика + pid процесса gunicorn).",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"refId": "A",
"expr": "sum by (instance) (rate(http_server_request_duration_seconds_count{job=\"messenger-api\", http_route!~\"/health/.*\", http_route=~\"$route\", instance=~\"$instance\"}[$__rate_interval]))",
"legendFormat": "{{instance}}",
"range": true,
"exemplar": false
}
],
"fieldConfig": {
"defaults": {
"unit": "reqps",
"custom": {
"drawStyle": "line",
"lineWidth": 1,
"fillOpacity": 10,
"showPoints": "never",
"spanNulls": false,
"stacking": {
"mode": "none",
"group": "A"
}
},
"min": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "table",
"placement": "bottom",
"calcs": [
"lastNotNull",
"max"
]
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"id": 10,
"gridPos": {
"x": 0,
"y": 21,
"w": 12,
"h": 8
}
},
{
"type": "timeseries",
"title": "Активные запросы",
"description": "",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"targets": [
{
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"refId": "A",
"expr": "sum by (instance) (http_server_active_requests{job=\"messenger-api\"})",
"legendFormat": "{{instance}}",
"range": true,
"exemplar": false
}
],
"fieldConfig": {
"defaults": {
"unit": "short",
"custom": {
"drawStyle": "line",
"lineWidth": 1,
"fillOpacity": 10,
"showPoints": "never",
"spanNulls": false,
"stacking": {
"mode": "none",
"group": "A"
}
},
"min": 0
},
"overrides": []
},
"options": {
"legend": {
"displayMode": "table",
"placement": "bottom",
"calcs": [
"lastNotNull",
"max"
]
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
},
"id": 11,
"gridPos": {
"x": 12,
"y": 21,
"w": 12,
"h": 8
}
},
{
"type": "row",
"title": "Логи и трассы API",
"collapsed": false,
"panels": [],
"id": 12,
"gridPos": {
"x": 0,
"y": 29,
"w": 24,
"h": 1
}
},
{
"type": "logs",
"title": "Логи API (ошибки и предупреждения)",
"datasource": {
"type": "loki",
"uid": "loki"
},
"targets": [
{
"datasource": {
"type": "loki",
"uid": "loki"
},
"refId": "A",
"expr": "{service_name=\"messenger-api\"} | severity_text=~\"(?i)error|warn.*\"",
"queryType": "range"
}
],
"options": {
"showTime": true,
"wrapLogMessage": true,
"sortOrder": "Descending",
"enableLogDetails": true,
"dedupStrategy": "none",
"prettifyLogMessage": false
},
"id": 13,
"gridPos": {
"x": 0,
"y": 30,
"w": 12,
"h": 10
}
},
{
"type": "table",
"title": "Трассы API с ошибкой",
"datasource": {
"type": "tempo",
"uid": "tempo"
},
"targets": [
{
"datasource": {
"type": "tempo",
"uid": "tempo"
},
"refId": "A",
"queryType": "traceql",
"query": "{ resource.service.name = \"messenger-api\" && status = error }",
"limit": 20,
"tableType": "traces"
}
],
"fieldConfig": {
"defaults": {},
"overrides": []
},
"options": {},
"id": 14,
"gridPos": {
"x": 12,
"y": 30,
"w": 12,
"h": 10
}
}
]
}