Files
mtusi2026lab7-fork/infra/grafana/dashboards/messenger-observability.json
T
2026-11-23 14:39:13 +03:00

670 lines
15 KiB
JSON

{
"uid": "messenger-observability",
"title": "Messenger: observability (lab 6)",
"tags": [
"messenger",
"lab6"
],
"timezone": "browser",
"schemaVersion": 39,
"version": 1,
"refresh": "10s",
"time": {
"from": "now-30m",
"to": "now"
},
"editable": false,
"panels": [
{
"id": 1,
"type": "stat",
"title": "API availability SLI (SLO 99 % / 30 d)",
"description": "SLI = 1 - 5xx / all business requests (health excluded; 4xx are client errors). Window = dashboard time range (set 30d to read the SLO). Query: 1 - sum(increase(http_server_request_duration_seconds_count{5xx}[$__range])) / sum(increase(..._count[$__range])).",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 0,
"w": 8,
"h": 4
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "1 - (sum(increase(http_server_request_duration_seconds_count{service_name=\"messenger-api\",http_response_status_class=\"5xx\"}[$__range])) / sum(increase(http_server_request_duration_seconds_count{service_name=\"messenger-api\"}[$__range])))",
"legendFormat": "availability"
}
],
"fieldConfig": {
"defaults": {
"unit": "percentunit",
"min": 0.9,
"max": 1,
"decimals": 3,
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "red",
"value": null
},
{
"color": "green",
"value": 0.99
}
]
}
},
"overrides": []
},
"options": {
"colorMode": "background",
"reduceOptions": {
"calcs": [
"lastNotNull"
]
}
}
},
{
"id": 2,
"type": "timeseries",
"title": "Alert state (pending / firing)",
"description": "ALERTS{} series written by Prometheus rule evaluation: shows pending -> firing -> gone (resolved).",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 8,
"y": 0,
"w": 16,
"h": 4
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (alertname, alertstate) (ALERTS)",
"legendFormat": "{{alertname}} {{alertstate}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "short"
},
"overrides": []
},
"options": {}
},
{
"id": 3,
"type": "timeseries",
"title": "API RPS by route",
"description": "Query: sum by (http_route)(rate(http_server_request_duration_seconds_count[1m])). Unit: requests/s. Route is a TEMPLATE, never a real UUID.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 4,
"w": 8,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (http_route) (rate(http_server_request_duration_seconds_count{service_name=\"messenger-api\"}[1m]))",
"legendFormat": "{{http_route}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "reqps"
},
"overrides": []
},
"options": {}
},
{
"id": 4,
"type": "timeseries",
"title": "API 5xx error ratio",
"description": "numerator = 5xx business requests, denominator = all business requests (health excluded). Unit: ratio 0..1.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 8,
"y": 4,
"w": 8,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(rate(http_server_request_duration_seconds_count{service_name=\"messenger-api\",http_response_status_class=\"5xx\"}[2m])) / sum(rate(http_server_request_duration_seconds_count{service_name=\"messenger-api\"}[2m]))",
"legendFormat": "5xx / all"
}
],
"fieldConfig": {
"defaults": {
"unit": "percentunit",
"min": 0
},
"overrides": []
},
"options": {}
},
{
"id": 5,
"type": "timeseries",
"title": "API latency p50 / p95 / p99",
"description": "histogram_quantile(q, sum by (le)(rate(http_server_request_duration_seconds_bucket[2m]))): buckets of ALL replicas are summed first. Averages of per-replica percentiles are mathematically wrong. Unit: seconds.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 16,
"y": 4,
"w": 8,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "histogram_quantile(0.5, sum by (le) (rate(http_server_request_duration_seconds_bucket{service_name=\"messenger-api\"}[2m])))",
"legendFormat": "p50"
},
{
"refId": "B",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "histogram_quantile(0.95, sum by (le) (rate(http_server_request_duration_seconds_bucket{service_name=\"messenger-api\"}[2m])))",
"legendFormat": "p95"
},
{
"refId": "C",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "histogram_quantile(0.99, sum by (le) (rate(http_server_request_duration_seconds_bucket{service_name=\"messenger-api\"}[2m])))",
"legendFormat": "p99"
}
],
"fieldConfig": {
"defaults": {
"unit": "s"
},
"overrides": []
},
"options": {}
},
{
"id": 6,
"type": "timeseries",
"title": "Jobs by outcome",
"description": "Counter of finished attempts: success | retry | failed | lost | noop | error. Unit: attempts/s.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 12,
"w": 8,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (outcome) (rate(messenger_jobs_processed_total[1m]))",
"legendFormat": "{{outcome}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "ops"
},
"overrides": []
},
"options": {}
},
{
"id": 7,
"type": "timeseries",
"title": "Worker job duration p50 / p95 / p99",
"description": "Processing time of one attempt (claim -> outcome). Does NOT include waiting in the queue (that is queue age). Unit: seconds.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 8,
"y": 12,
"w": 8,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "histogram_quantile(0.5, sum by (le) (rate(messenger_job_duration_seconds_bucket{}[2m])))",
"legendFormat": "p50"
},
{
"refId": "B",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_job_duration_seconds_bucket{}[2m])))",
"legendFormat": "p95"
},
{
"refId": "C",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "histogram_quantile(0.99, sum by (le) (rate(messenger_job_duration_seconds_bucket{}[2m])))",
"legendFormat": "p99"
}
],
"fieldConfig": {
"defaults": {
"unit": "s"
},
"overrides": []
},
"options": {}
},
{
"id": 8,
"type": "timeseries",
"title": "Time to ready p50 / p95 / p99",
"description": "End-to-end: durable acceptance (job row) -> ready commit, incl. backlog, retries and backoff. Unit: seconds.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 16,
"y": 12,
"w": 8,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "histogram_quantile(0.5, sum by (le) (rate(messenger_job_time_to_ready_seconds_bucket{}[5m])))",
"legendFormat": "p50"
},
{
"refId": "B",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_job_time_to_ready_seconds_bucket{}[5m])))",
"legendFormat": "p95"
},
{
"refId": "C",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "histogram_quantile(0.99, sum by (le) (rate(messenger_job_time_to_ready_seconds_bucket{}[5m])))",
"legendFormat": "p99"
}
],
"fieldConfig": {
"defaults": {
"unit": "s"
},
"overrides": []
},
"options": {}
},
{
"id": 9,
"type": "timeseries",
"title": "Queue depth",
"description": "Jobs with status=queued whose backoff has elapsed (waiting for a worker). Computed by the dispatcher from PostgreSQL. Unit: jobs.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 20,
"w": 6,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "max by (queue_name) (messenger_queue_depth)",
"legendFormat": "{{queue_name}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "short"
},
"overrides": []
},
"options": {}
},
{
"id": 10,
"type": "timeseries",
"title": "Oldest waiting job age",
"description": "now - min(next_attempt_at) over due queued jobs; 0 when empty. Alert QueueLagGrowing: > 30 s for 1 m. Unit: seconds.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 6,
"y": 20,
"w": 6,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "max by (queue_name) (messenger_queue_oldest_job_age_seconds)",
"legendFormat": "{{queue_name}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "s"
},
"overrides": []
},
"options": {}
},
{
"id": 11,
"type": "timeseries",
"title": "Worker busy vs capacity",
"description": "busy = jobs handled right now, capacity = WORKER_CONCURRENCY. Saturation = busy / capacity. Unit: jobs.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 12,
"y": 20,
"w": 6,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(messenger_worker_busy)",
"legendFormat": "busy"
},
{
"refId": "B",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(messenger_worker_capacity)",
"legendFormat": "capacity"
}
],
"fieldConfig": {
"defaults": {
"unit": "short"
},
"overrides": []
},
"options": {}
},
{
"id": 12,
"type": "timeseries",
"title": "DB pool used / waiting (API)",
"description": "psycopg_pool stats: connections checked out, requests waiting for a connection. waiting > 0 = pool saturation. Unit: connections / requests.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 18,
"y": 20,
"w": 6,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (service_instance_id) (messenger_db_pool_used)",
"legendFormat": "used {{service_instance_id}}"
},
{
"refId": "B",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum(messenger_db_pool_waiting)",
"legendFormat": "waiting (all)"
}
],
"fieldConfig": {
"defaults": {
"unit": "short"
},
"overrides": []
},
"options": {}
},
{
"id": 13,
"type": "timeseries",
"title": "CPU by service (cores)",
"description": "rate of process CPU seconds (user+system) of the main process. Unit: CPU cores.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 0,
"y": 28,
"w": 8,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (service_name) (rate(process_cpu_time_seconds_total[1m]))",
"legendFormat": "{{service_name}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "short"
},
"overrides": []
},
"options": {}
},
{
"id": 14,
"type": "timeseries",
"title": "Memory (RSS) by service",
"description": "Resident set size of the main process. Unit: bytes.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 8,
"y": 28,
"w": 8,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (service_name, service_instance_id) (process_memory_usage_bytes)",
"legendFormat": "{{service_name}} {{service_instance_id}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "bytes"
},
"overrides": []
},
"options": {}
},
{
"id": 15,
"type": "timeseries",
"title": "Telemetry loss in the Collector",
"description": "Failed exporter sends and memory_limiter refusals (spans / metric points / log records per second). Non-zero while a backend is down: telemetry is lost, the API is not affected.",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"gridPos": {
"x": 16,
"y": 28,
"w": 8,
"h": 8
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "prometheus",
"uid": "prometheus"
},
"expr": "sum by (__name__) (rate({__name__=~\"otelcol_(exporter_send_failed|processor_refused)_.*_total\",job=\"otel-collector\"}[1m]))",
"legendFormat": "{{__name__}}"
}
],
"fieldConfig": {
"defaults": {
"unit": "short"
},
"overrides": []
},
"options": {}
},
{
"id": 16,
"type": "logs",
"title": "Warnings and errors (all services)",
"description": "Loki (OTLP). Click trace_id to open the trace in Tempo. Filter one trace: {service_name=~\"messenger-.+\"} | trace_id=\"<id>\".",
"datasource": {
"type": "loki",
"uid": "loki"
},
"gridPos": {
"x": 0,
"y": 36,
"w": 24,
"h": 10
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "loki",
"uid": "loki"
},
"expr": "{service_name=~\"messenger-.+\"} | detected_level=~\"WARN|ERROR|CRITICAL\"",
"legendFormat": ""
}
],
"fieldConfig": {
"defaults": {
"unit": "short"
},
"overrides": []
},
"options": {
"showTime": true,
"wrapLogMessage": true,
"enableLogDetails": true,
"sortOrder": "Descending"
}
}
],
"templating": {
"list": []
},
"annotations": {
"list": []
}
}