Lab 7
Skeleton contracts / contracts (pull_request) Canceled after 0s

This commit is contained in:
2026-11-27 20:47:58 +03:00
parent 20afc2c790
commit d995f98446
97 changed files with 8638 additions and 56 deletions
+106
View File
@@ -0,0 +1,106 @@
{
"annotations": {"list": []},
"editable": true,
"graphTooltip": 1,
"title": "Messenger — API, worker, queue",
"uid": "messenger-lab6",
"schemaVersion": 39,
"version": 1,
"time": {"from": "now-30m", "to": "now"},
"refresh": "10s",
"templating": {"list": []},
"panels": [
{
"id": 1, "type": "timeseries", "title": "API RPS by route",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 0},
"fieldConfig": {"defaults": {"unit": "reqps"}, "overrides": []},
"targets": [{"expr": "sum by (route) (rate(http_server_requests_total[1m]))", "legendFormat": "{{route}}"}]
},
{
"id": 2, "type": "timeseries", "title": "API 5xx error ratio (business routes)",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"gridPos": {"h": 8, "w": 12, "x": 12, "y": 0},
"fieldConfig": {"defaults": {"unit": "percentunit"}, "overrides": []},
"targets": [{"expr": "sum(rate(http_server_requests_total{status_class=\"5xx\",route!~\".*health.*\"}[5m])) / clamp_min(sum(rate(http_server_requests_total{route!~\".*health.*\"}[5m])), 1)", "legendFormat": "5xx ratio"}]
},
{
"id": 3, "type": "timeseries", "title": "API latency p50/p95/p99 (histogram, ms)",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 8},
"fieldConfig": {"defaults": {"unit": "ms"}, "overrides": []},
"targets": [
{"expr": "histogram_quantile(0.50, sum by (le) (rate(http_server_duration_milliseconds_bucket[5m])))", "legendFormat": "p50"},
{"expr": "histogram_quantile(0.95, sum by (le) (rate(http_server_duration_milliseconds_bucket[5m])))", "legendFormat": "p95"},
{"expr": "histogram_quantile(0.99, sum by (le) (rate(http_server_duration_milliseconds_bucket[5m])))", "legendFormat": "p99"}
]
},
{
"id": 4, "type": "timeseries", "title": "Jobs processed/s by outcome",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"gridPos": {"h": 8, "w": 12, "x": 12, "y": 8},
"fieldConfig": {"defaults": {"unit": "ops"}, "overrides": []},
"targets": [{"expr": "sum by (outcome) (rate(messenger_jobs_processed_total[5m]))", "legendFormat": "{{outcome}}"}]
},
{
"id": 5, "type": "timeseries", "title": "Job duration p95 / time-to-ready p95 (histogram)",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 16},
"fieldConfig": {"defaults": {"unit": "s"}, "overrides": []},
"targets": [
{"expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_jobs_duration_bucket[5m])))", "legendFormat": "job p95"},
{"expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_attachment_time_to_ready_bucket[5m])))", "legendFormat": "time-to-ready p95"}
]
},
{
"id": 6, "type": "timeseries", "title": "Queue depth / oldest job age",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"gridPos": {"h": 8, "w": 12, "x": 12, "y": 16},
"fieldConfig": {"defaults": {}, "overrides": []},
"targets": [
{"expr": "max(messenger_queue_depth)", "legendFormat": "depth"},
{"expr": "max(messenger_queue_oldest_job_age_seconds)", "legendFormat": "oldest age (s)"}
]
},
{
"id": 7, "type": "timeseries", "title": "DB pool used / waiting",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 24},
"fieldConfig": {"defaults": {}, "overrides": []},
"targets": [
{"expr": "max(messenger_db_pool_used)", "legendFormat": "used"},
{"expr": "max(messenger_db_pool_waiting)", "legendFormat": "waiting"}
]
},
{
"id": 8, "type": "timeseries", "title": "Worker busy / capacity",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"gridPos": {"h": 8, "w": 12, "x": 12, "y": 24},
"fieldConfig": {"defaults": {}, "overrides": []},
"targets": [
{"expr": "sum(messenger_worker_busy)", "legendFormat": "busy"},
{"expr": "sum(messenger_worker_capacity)", "legendFormat": "capacity"}
]
},
{
"id": 9, "type": "timeseries", "title": "Process memory (API + worker)",
"datasource": {"type": "prometheus", "uid": "prometheus"},
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 32},
"fieldConfig": {"defaults": {"unit": "bytes"}, "overrides": []},
"targets": [{"expr": "sum by (service_name) (process_memory_usage_bytes)", "legendFormat": "{{service_name}}"}]
},
{
"id": 10, "type": "logs", "title": "API logs (Loki) — JSON with trace_id",
"datasource": {"type": "loki", "uid": "loki"},
"gridPos": {"h": 8, "w": 12, "x": 12, "y": 32},
"options": {"showTime": true, "wrapLogMessage": true},
"targets": [{"expr": "{service_name=\"messenger-api\"} | json"}]
},
{
"id": 11, "type": "traces", "title": "Traces (Tempo)",
"datasource": {"type": "tempo", "uid": "tempo"},
"gridPos": {"h": 8, "w": 24, "x": 0, "y": 40},
"targets": [{"query": "{}", "queryType": "traceql"}]
}
]
}
@@ -0,0 +1,11 @@
apiVersion: 1
providers:
- name: messenger
orgId: 1
folder: Messenger
type: file
disableDeletion: false
updateIntervalSeconds: 30
options:
path: /var/lib/grafana/dashboards
@@ -0,0 +1,40 @@
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
uid: prometheus
isDefault: true
jsonData:
timeInterval: 10s
- name: Loki
type: loki
access: proxy
url: http://loki:3100
uid: loki
jsonData:
derivedFields:
- name: trace_id
matcherType: label
matcherRegex: trace_id
datasourceUid: tempo
url: "$${__value.raw}"
urlDisplayLabel: "View trace"
- name: Tempo
type: tempo
access: proxy
url: http://tempo:3200
uid: tempo
jsonData:
tracesToLogsV2:
datasourceUid: loki
spanStartTimeShift: "-1m"
spanEndTimeShift: "1m"
filterByTraceID: true
tags:
- key: service.name
value: service_name