forked from mtusi2026/mtusi2026lab6
lab6
This commit is contained in:
+17
-6
@@ -1,7 +1,18 @@
|
||||
# Инфраструктура студента
|
||||
# Инфраструктура lab6
|
||||
|
||||
Здесь разместите конфигурации выбранных сервисов; основную топологию — в корневом compose.yaml/stack.yaml. `compose.example.yaml` — только worksheet ролей и намеренно не запускается. `contracts/infrastructure.json` задаёт минимальные роли, не готовые образы/пароли.
|
||||
|
||||
В REPORT.md сопоставьте роль → service name → версия/digest → health/readiness → volume → сеть/порт → способ передачи credentials. Приведите bootstrap (schema, bucket, broker topology, а с lab6 provisioning) и безопасное повторение этих команд.
|
||||
|
||||
Приложение строится из исходников. Не используйте заранее существующий образ преподавательского сервера вместо своей реализации. Restart hook перезапускает все соответствующие stores с volumes; failover hook останавливает только заданную API-реплику.
|
||||
- `otel/collector.yaml` — OTLP receivers, memory_limiter (140 MiB), batch,
|
||||
bounded Loki/Tempo exporter queues (`sizer: bytes`), Prometheus exporter
|
||||
`:8889`, self-metrics `:8888`, health `:13133`.
|
||||
- `prometheus/` — scrape config (collector, collector-self, HAProxy, RabbitMQ),
|
||||
7d/2GB retention, SLO recording rules and alerts.
|
||||
- `loki/loki.yaml` — filesystem, schema v13, 168h retention, OTLP mapping with
|
||||
only `service.name`/`deployment.environment.name` as index labels.
|
||||
- `tempo/tempo.yaml` — local storage, OTLP, 72h block retention.
|
||||
- `grafana/` — provisioned datasources (Prometheus/Loki/Tempo), dashboard
|
||||
provider and JSON dashboards; admin password only in gitignored
|
||||
`secrets/grafana.env`.
|
||||
- `rabbitmq/rabbitmq.conf` — per-object Prometheus metrics so `queue` is a
|
||||
real label for depth/age panels.
|
||||
- `runbooks/` — DB availability, queue lag, API errors, telemetry backend down.
|
||||
- cAdvisor не используется: контейнерные CPU/RAM приложения снимаются из
|
||||
cgroup v2, брокер — из `rabbitmq_prometheus`; Docker socket не монтируется.
|
||||
|
||||
@@ -0,0 +1,582 @@
|
||||
{
|
||||
"annotations": {
|
||||
"list": []
|
||||
},
|
||||
"editable": false,
|
||||
"graphTooltip": 1,
|
||||
"panels": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "API RPS",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(rate(messenger_http_server_requests_total[5m]))",
|
||||
"legendFormat": "rps",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "reqps"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"title": "API error ratio (edge SLI)",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 0
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "slo:api_error_ratio:5m",
|
||||
"legendFormat": "5xx ratio",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "slo:api_error_ratio:1h",
|
||||
"legendFormat": "1h",
|
||||
"refId": "B",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percentunit"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"title": "API latency p50/p95/p99",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 7
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "histogram_quantile(0.50, sum by (le) (rate(http_server_request_duration_seconds_bucket[5m])))",
|
||||
"legendFormat": "p50",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "histogram_quantile(0.95, sum by (le) (rate(http_server_request_duration_seconds_bucket[5m])))",
|
||||
"legendFormat": "p95",
|
||||
"refId": "B",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "histogram_quantile(0.99, sum by (le) (rate(http_server_request_duration_seconds_bucket[5m])))",
|
||||
"legendFormat": "p99",
|
||||
"refId": "C",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"title": "Jobs processed / failed / retried",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 7
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(rate(messenger_jobs_processed_total{outcome=\"succeeded\"}[5m]))",
|
||||
"legendFormat": "succeeded",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(rate(messenger_jobs_processed_total{outcome=\"failed\"}[5m]))",
|
||||
"legendFormat": "failed",
|
||||
"refId": "B",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(rate(messenger_jobs_processed_total{outcome=\"retried\"}[5m]))",
|
||||
"legendFormat": "retried",
|
||||
"refId": "C",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "ops"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"title": "Time-to-ready p50/p95/p99",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 14
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "histogram_quantile(0.50, sum by (le) (rate(messenger_job_time_to_ready_seconds_bucket[5m])))",
|
||||
"legendFormat": "p50",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"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": "B",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "histogram_quantile(0.99, sum by (le) (rate(messenger_job_time_to_ready_seconds_bucket[5m])))",
|
||||
"legendFormat": "p99",
|
||||
"refId": "C",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"title": "TTR bad ratio (1 - within 30s / accepted)",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 14
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "slo:ttr_bad_ratio:5m",
|
||||
"legendFormat": "5m",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "slo:ttr_bad_ratio:1h",
|
||||
"legendFormat": "1h",
|
||||
"refId": "B",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percentunit"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"title": "Queue depth",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 8,
|
||||
"x": 0,
|
||||
"y": 21
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "max(rabbitmq_queue_messages_ready{queue=\"attachment.process.v1\"})",
|
||||
"legendFormat": "ready",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"title": "Oldest job age",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 8,
|
||||
"x": 8,
|
||||
"y": 21
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "max(messenger_queue_oldest_job_age_seconds)",
|
||||
"legendFormat": "oldest job seconds",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"title": "Worker saturation",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 8,
|
||||
"x": 16,
|
||||
"y": 21
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(messenger_worker_busy)",
|
||||
"legendFormat": "busy",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(messenger_worker_capacity)",
|
||||
"legendFormat": "capacity",
|
||||
"refId": "B",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"title": "DB pool used / idle / max",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 28
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(messenger_db_pool_used)",
|
||||
"legendFormat": "used",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(messenger_db_pool_idle)",
|
||||
"legendFormat": "idle",
|
||||
"refId": "B",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(messenger_db_pool_max)",
|
||||
"legendFormat": "max",
|
||||
"refId": "C",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"title": "DB empty acquire / wait",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 28
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(rate(messenger_db_pool_empty_acquire_total[5m]))",
|
||||
"legendFormat": "empty acquire/s",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(rate(messenger_db_pool_empty_acquire_wait_seconds_total[5m]))",
|
||||
"legendFormat": "wait seconds/s",
|
||||
"refId": "B",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"title": "API logs",
|
||||
"type": "logs",
|
||||
"gridPos": {
|
||||
"h": 9,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 35
|
||||
},
|
||||
"datasource": {
|
||||
"type": "loki",
|
||||
"uid": "loki"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "loki",
|
||||
"uid": "loki"
|
||||
},
|
||||
"expr": "{service_name=\"messenger-api\"}",
|
||||
"refId": "A",
|
||||
"queryType": "range"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 13,
|
||||
"title": "Traces: job.process",
|
||||
"type": "traces",
|
||||
"gridPos": {
|
||||
"h": 9,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 35
|
||||
},
|
||||
"datasource": {
|
||||
"type": "tempo",
|
||||
"uid": "tempo"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "tempo",
|
||||
"uid": "tempo"
|
||||
},
|
||||
"query": "{ name = \"job.process\" }",
|
||||
"refId": "A",
|
||||
"queryType": "traceql"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
}
|
||||
],
|
||||
"refresh": "5s",
|
||||
"schemaVersion": 39,
|
||||
"tags": [
|
||||
"lab6",
|
||||
"messenger"
|
||||
],
|
||||
"templating": {
|
||||
"list": []
|
||||
},
|
||||
"time": {
|
||||
"from": "now-30m",
|
||||
"to": "now"
|
||||
},
|
||||
"timezone": "browser",
|
||||
"title": "Lab6 — messenger observability",
|
||||
"uid": "lab6-overview",
|
||||
"version": 1
|
||||
}
|
||||
@@ -0,0 +1,343 @@
|
||||
{
|
||||
"annotations": {
|
||||
"list": []
|
||||
},
|
||||
"editable": false,
|
||||
"panels": [
|
||||
{
|
||||
"id": 1,
|
||||
"title": "API RPS",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(rate(messenger_http_server_requests_total[5m]))",
|
||||
"legendFormat": "rps",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "reqps"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"title": "API latency p50/p95/p99",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 7
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "histogram_quantile(0.50, sum by (le) (rate(http_server_request_duration_seconds_bucket[5m])))",
|
||||
"legendFormat": "p50",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "histogram_quantile(0.95, sum by (le) (rate(http_server_request_duration_seconds_bucket[5m])))",
|
||||
"legendFormat": "p95",
|
||||
"refId": "B",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "histogram_quantile(0.99, sum by (le) (rate(http_server_request_duration_seconds_bucket[5m])))",
|
||||
"legendFormat": "p99",
|
||||
"refId": "C",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"title": "DB pool used / idle / max",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 28
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(messenger_db_pool_used)",
|
||||
"legendFormat": "used",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(messenger_db_pool_idle)",
|
||||
"legendFormat": "idle",
|
||||
"refId": "B",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(messenger_db_pool_max)",
|
||||
"legendFormat": "max",
|
||||
"refId": "C",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"title": "DB empty acquire / wait",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 28
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(rate(messenger_db_pool_empty_acquire_total[5m]))",
|
||||
"legendFormat": "empty acquire/s",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(rate(messenger_db_pool_empty_acquire_wait_seconds_total[5m]))",
|
||||
"legendFormat": "wait seconds/s",
|
||||
"refId": "B",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"title": "API logs",
|
||||
"type": "logs",
|
||||
"gridPos": {
|
||||
"h": 9,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 35
|
||||
},
|
||||
"datasource": {
|
||||
"type": "loki",
|
||||
"uid": "loki"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "loki",
|
||||
"uid": "loki"
|
||||
},
|
||||
"expr": "{service_name=\"messenger-api\"}",
|
||||
"refId": "A",
|
||||
"queryType": "range"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 30,
|
||||
"title": "Process memory usage",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 28
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum by (service_name) (messenger_process_memory_usage_bytes)",
|
||||
"legendFormat": "{{service_name}}",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "bytes"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 31,
|
||||
"title": "Collector exporter queue",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 28
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "max(otelcol_exporter_queue_size)",
|
||||
"legendFormat": "queue",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 32,
|
||||
"title": "Scrape targets up",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 35
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "up",
|
||||
"legendFormat": "{{job}}",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
}
|
||||
],
|
||||
"refresh": "5s",
|
||||
"schemaVersion": 39,
|
||||
"tags": [
|
||||
"lab6",
|
||||
"infra"
|
||||
],
|
||||
"templating": {
|
||||
"list": []
|
||||
},
|
||||
"time": {
|
||||
"from": "now-30m",
|
||||
"to": "now"
|
||||
},
|
||||
"title": "Lab6 — infrastructure saturation",
|
||||
"uid": "lab6-infra",
|
||||
"version": 1
|
||||
}
|
||||
@@ -0,0 +1,430 @@
|
||||
{
|
||||
"annotations": {
|
||||
"list": []
|
||||
},
|
||||
"editable": false,
|
||||
"panels": [
|
||||
{
|
||||
"id": 4,
|
||||
"title": "Jobs processed / failed / retried",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 7
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(rate(messenger_jobs_processed_total{outcome=\"succeeded\"}[5m]))",
|
||||
"legendFormat": "succeeded",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(rate(messenger_jobs_processed_total{outcome=\"failed\"}[5m]))",
|
||||
"legendFormat": "failed",
|
||||
"refId": "B",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(rate(messenger_jobs_processed_total{outcome=\"retried\"}[5m]))",
|
||||
"legendFormat": "retried",
|
||||
"refId": "C",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "ops"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"title": "Time-to-ready p50/p95/p99",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 14
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "histogram_quantile(0.50, sum by (le) (rate(messenger_job_time_to_ready_seconds_bucket[5m])))",
|
||||
"legendFormat": "p50",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"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": "B",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "histogram_quantile(0.99, sum by (le) (rate(messenger_job_time_to_ready_seconds_bucket[5m])))",
|
||||
"legendFormat": "p99",
|
||||
"refId": "C",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"title": "TTR bad ratio (1 - within 30s / accepted)",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 14
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "slo:ttr_bad_ratio:5m",
|
||||
"legendFormat": "5m",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "slo:ttr_bad_ratio:1h",
|
||||
"legendFormat": "1h",
|
||||
"refId": "B",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percentunit"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"title": "Queue depth",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 8,
|
||||
"x": 0,
|
||||
"y": 21
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "max(rabbitmq_queue_messages_ready{queue=\"attachment.process.v1\"})",
|
||||
"legendFormat": "ready",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"title": "Oldest job age",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 8,
|
||||
"x": 8,
|
||||
"y": 21
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "max(messenger_queue_oldest_job_age_seconds)",
|
||||
"legendFormat": "oldest job seconds",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"title": "Worker saturation",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 8,
|
||||
"x": 16,
|
||||
"y": 21
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(messenger_worker_busy)",
|
||||
"legendFormat": "busy",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(messenger_worker_capacity)",
|
||||
"legendFormat": "capacity",
|
||||
"refId": "B",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"title": "DB pool used / idle / max",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 28
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(messenger_db_pool_used)",
|
||||
"legendFormat": "used",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(messenger_db_pool_idle)",
|
||||
"legendFormat": "idle",
|
||||
"refId": "B",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(messenger_db_pool_max)",
|
||||
"legendFormat": "max",
|
||||
"refId": "C",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 20,
|
||||
"title": "Job duration p50/p95/p99",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 42
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "histogram_quantile(0.50, sum by (le) (rate(messenger_job_duration_seconds_bucket[5m])))",
|
||||
"legendFormat": "p50",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "histogram_quantile(0.95, sum by (le) (rate(messenger_job_duration_seconds_bucket[5m])))",
|
||||
"legendFormat": "p95",
|
||||
"refId": "B",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "histogram_quantile(0.99, sum by (le) (rate(messenger_job_duration_seconds_bucket[5m])))",
|
||||
"legendFormat": "p99",
|
||||
"refId": "C",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "s"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 21,
|
||||
"title": "Overdue jobs (>30s)",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 42
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "max(messenger_jobs_overdue)",
|
||||
"legendFormat": "overdue",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "short"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
}
|
||||
],
|
||||
"refresh": "5s",
|
||||
"schemaVersion": 39,
|
||||
"tags": [
|
||||
"lab6",
|
||||
"jobs"
|
||||
],
|
||||
"templating": {
|
||||
"list": []
|
||||
},
|
||||
"time": {
|
||||
"from": "now-30m",
|
||||
"to": "now"
|
||||
},
|
||||
"title": "Lab6 — jobs and queue",
|
||||
"uid": "lab6-jobs",
|
||||
"version": 1
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
apiVersion: 1
|
||||
providers:
|
||||
- name: lab6
|
||||
orgId: 1
|
||||
folder: Lab6
|
||||
type: file
|
||||
disableDeletion: false
|
||||
updateIntervalSeconds: 10
|
||||
options:
|
||||
path: /var/lib/grafana/dashboards
|
||||
@@ -0,0 +1,36 @@
|
||||
apiVersion: 1
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
uid: prometheus
|
||||
type: prometheus
|
||||
access: proxy
|
||||
url: http://prometheus:9090
|
||||
isDefault: true
|
||||
editable: false
|
||||
- name: Loki
|
||||
uid: loki
|
||||
type: loki
|
||||
access: proxy
|
||||
url: http://loki:3100
|
||||
editable: false
|
||||
jsonData:
|
||||
derivedFields:
|
||||
- datasourceUid: tempo
|
||||
matcherType: label
|
||||
matcherRegex: trace_id
|
||||
url: "$${__value.raw}"
|
||||
urlDisplayLabel: Open trace
|
||||
- name: Tempo
|
||||
uid: tempo
|
||||
type: tempo
|
||||
access: proxy
|
||||
url: http://tempo:3200
|
||||
editable: false
|
||||
jsonData:
|
||||
tracesToLogs:
|
||||
datasourceUid: loki
|
||||
tags:
|
||||
- key: service.name
|
||||
value: service_name
|
||||
- key: trace_id
|
||||
value: trace_id
|
||||
@@ -18,7 +18,7 @@ global
|
||||
defaults
|
||||
mode http
|
||||
log global
|
||||
option httplog
|
||||
log-format "%ST %Tt %b"
|
||||
option dontlognull
|
||||
timeout connect 1s
|
||||
timeout client 70s
|
||||
@@ -70,7 +70,11 @@ frontend http_front
|
||||
frontend stats_front
|
||||
# Только для оператора и доказательств: видно, какие реплики UP/DOWN и почему.
|
||||
bind *:8404
|
||||
# Built-in Prometheus exporter (HAProxy built with USE_PROMEX). The edge SLI
|
||||
# uses frontend response codes; health checks are not counted here.
|
||||
http-request use-service prometheus-exporter if { path /metrics }
|
||||
stats enable
|
||||
stats uri /stats
|
||||
stats refresh 2s
|
||||
monitor-uri /healthz
|
||||
no log
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
auth_enabled: false
|
||||
|
||||
server:
|
||||
http_listen_port: 3100
|
||||
grpc_listen_port: 9096
|
||||
|
||||
common:
|
||||
path_prefix: /loki
|
||||
storage:
|
||||
filesystem:
|
||||
chunks_directory: /loki/chunks
|
||||
rules_directory: /loki/rules
|
||||
replication_factor: 1
|
||||
ring:
|
||||
kvstore:
|
||||
store: inmemory
|
||||
|
||||
schema_config:
|
||||
configs:
|
||||
- from: 2024-01-01
|
||||
store: tsdb
|
||||
object_store: filesystem
|
||||
schema: v13
|
||||
index:
|
||||
prefix: index_
|
||||
period: 24h
|
||||
|
||||
storage_config:
|
||||
filesystem:
|
||||
directory: /loki/storage
|
||||
tsdb_shipper:
|
||||
active_index_directory: /loki/tsdb-index
|
||||
cache_location: /loki/tsdb-cache
|
||||
|
||||
limits_config:
|
||||
retention_period: 168h
|
||||
allow_structured_metadata: true
|
||||
max_line_size: 32KB
|
||||
max_line_size_truncate: true
|
||||
otlp_config:
|
||||
resource_attributes:
|
||||
ignore_defaults: true
|
||||
attributes_config:
|
||||
- action: index_label
|
||||
attributes:
|
||||
- service.name
|
||||
- deployment.environment.name
|
||||
- action: structured_metadata
|
||||
attributes:
|
||||
- service.instance.id
|
||||
- service.version
|
||||
log_attributes:
|
||||
- action: structured_metadata
|
||||
regex: .*
|
||||
|
||||
compactor:
|
||||
working_directory: /loki/compactor
|
||||
retention_enabled: true
|
||||
delete_request_store: filesystem
|
||||
|
||||
ruler:
|
||||
storage:
|
||||
type: local
|
||||
local:
|
||||
directory: /loki/rules
|
||||
+11
-5
@@ -1,7 +1,13 @@
|
||||
# Конфигурация наблюдаемости — реализовать
|
||||
# OTel Collector
|
||||
|
||||
Добавьте `collector.yaml` с OTLP receivers, processors и exporters выбранной версии Collector. Укажите явные bind endpoints, внутренние сети, memory limits/batch и поведение при backpressure по уровню. Сопоставьте все три pipeline с реально развёрнутыми backend.
|
||||
`collector.yaml` — единственный OTLP-приёмник стенда. API/worker/relay шлют
|
||||
traces/metrics/logs по HTTP `:4318`; Collector экспортирует:
|
||||
- метрики — pull-exporter Prometheus `:8889` (Prometheus scrape);
|
||||
- логи — OTLP HTTP в Loki `/otlp`;
|
||||
- трассы — OTLP gRPC в Tempo `:4317`.
|
||||
|
||||
Добавьте конфигурации storage, Grafana provisioning/datasources, provisioning/dashboards и импортируемые dashboard JSON. На 4 — alert rules и runbooks. Пустой dashboard или debug exporter, который только печатает данные в stdout, не заменяют хранилища/доказательства из `contracts/observability.md`.
|
||||
|
||||
Не публикуйте OTLP/metrics/административные ports в общую сеть без необходимости. В lab7 реализуйте TLS/mTLS по trust matrix; экспорт Authorization и message bodies запрещён.
|
||||
`memory_limiter` ограничивает 140 MiB, batch — 5 с/1024, очереди Loki/Tempo
|
||||
ограничены 10 MiB (`sizer: bytes`) и retry не дольше 30 с. Self-metrics
|
||||
Collector отдаются на `:8888` отдельным scrape-job. OTLP-порты не публикуются
|
||||
на host; Collector подключён к `default` и `observability`, backend'ы — только
|
||||
к `observability`. TLS/auth относятся к lab7.
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
grpc:
|
||||
endpoint: 0.0.0.0:4317
|
||||
http:
|
||||
endpoint: 0.0.0.0:4318
|
||||
|
||||
processors:
|
||||
memory_limiter:
|
||||
check_interval: 1s
|
||||
# limit_mib, not limit_percentage: Docker Desktop cgroup limits are easy to
|
||||
# misread and a percentage would fall back to the VM total.
|
||||
limit_mib: 140
|
||||
spike_limit_mib: 40
|
||||
batch:
|
||||
timeout: 5s
|
||||
send_batch_size: 1024
|
||||
|
||||
exporters:
|
||||
# Pull-based: no sending_queue/retry for this exporter.
|
||||
prometheus:
|
||||
endpoint: 0.0.0.0:8889
|
||||
translation_strategy: UnderscoreEscapingWithSuffixes
|
||||
resource_constant_labels:
|
||||
included:
|
||||
- service.name
|
||||
- service.instance.id
|
||||
- deployment.environment.name
|
||||
- service.version
|
||||
otlp_http/loki:
|
||||
endpoint: http://loki:3100/otlp
|
||||
sending_queue:
|
||||
enabled: true
|
||||
sizer: bytes
|
||||
queue_size: 10485760
|
||||
num_consumers: 2
|
||||
retry_on_failure:
|
||||
enabled: true
|
||||
initial_interval: 1s
|
||||
max_interval: 5s
|
||||
max_elapsed_time: 30s
|
||||
timeout: 5s
|
||||
otlp_grpc/tempo:
|
||||
endpoint: tempo:4317
|
||||
tls:
|
||||
insecure: true
|
||||
sending_queue:
|
||||
enabled: true
|
||||
sizer: bytes
|
||||
queue_size: 10485760
|
||||
num_consumers: 2
|
||||
retry_on_failure:
|
||||
enabled: true
|
||||
initial_interval: 1s
|
||||
max_interval: 5s
|
||||
max_elapsed_time: 30s
|
||||
timeout: 5s
|
||||
|
||||
extensions:
|
||||
health_check:
|
||||
endpoint: 0.0.0.0:13133
|
||||
|
||||
service:
|
||||
extensions: [health_check]
|
||||
telemetry:
|
||||
metrics:
|
||||
readers:
|
||||
- pull:
|
||||
exporter:
|
||||
prometheus:
|
||||
host: 0.0.0.0
|
||||
port: 8888
|
||||
pipelines:
|
||||
traces:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [otlp_grpc/tempo]
|
||||
metrics:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [prometheus]
|
||||
logs:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [otlp_http/loki]
|
||||
@@ -0,0 +1,24 @@
|
||||
global:
|
||||
scrape_interval: 5s
|
||||
evaluation_interval: 5s
|
||||
|
||||
rule_files:
|
||||
- /etc/prometheus/rules/*.yml
|
||||
|
||||
scrape_configs:
|
||||
- job_name: otel-collector
|
||||
static_configs:
|
||||
- targets: ["otel-collector:8889"]
|
||||
- job_name: otel-collector-self
|
||||
static_configs:
|
||||
- targets: ["otel-collector:8888"]
|
||||
- job_name: haproxy
|
||||
metrics_path: /metrics
|
||||
static_configs:
|
||||
- targets: ["lb:8404"]
|
||||
- job_name: rabbitmq
|
||||
static_configs:
|
||||
- targets: ["broker:15692"]
|
||||
- job_name: loki
|
||||
static_configs:
|
||||
- targets: ["loki:3100"]
|
||||
@@ -0,0 +1,142 @@
|
||||
groups:
|
||||
- name: lab6-alerts
|
||||
interval: 5s
|
||||
rules:
|
||||
- alert: APIErrorBudgetFastBurn
|
||||
expr: slo:api_error_ratio:1h > 0.072 and slo:api_error_ratio:5m > 0.072 and on() sum(increase(haproxy_frontend_http_responses_total{proxy="http_front"}[5m])) >= 20
|
||||
for: 0s
|
||||
labels:
|
||||
severity: page
|
||||
slo: api-availability
|
||||
annotations:
|
||||
summary: API 5xx burn rate is above 14.4x
|
||||
runbook: infra/runbooks/slo-burn.md
|
||||
- alert: APIErrorBudgetSlowBurn
|
||||
expr: slo:api_error_ratio:6h > 0.03 and slo:api_error_ratio:30m > 0.03 and on() sum(increase(haproxy_frontend_http_responses_total{proxy="http_front"}[30m])) >= 100
|
||||
for: 0s
|
||||
labels:
|
||||
severity: ticket
|
||||
slo: api-availability
|
||||
annotations:
|
||||
summary: API 5xx burn rate is above 6x
|
||||
runbook: infra/runbooks/slo-burn.md
|
||||
- alert: TTRErrorBudgetFastBurn
|
||||
expr: slo:ttr_bad_ratio:1h > 0.144 and slo:ttr_bad_ratio:5m > 0.144 and on() sum(increase(messenger_jobs_accepted_total[5m])) >= 2
|
||||
for: 0s
|
||||
labels:
|
||||
severity: page
|
||||
slo: time-to-ready
|
||||
annotations:
|
||||
summary: Jobs are missing the 30s time-to-ready objective
|
||||
runbook: infra/runbooks/queue-lag.md
|
||||
- alert: TTRErrorBudgetSlowBurn
|
||||
expr: slo:ttr_bad_ratio:6h > 0.06 and slo:ttr_bad_ratio:30m > 0.06 and on() sum(increase(messenger_jobs_accepted_total[30m])) >= 10
|
||||
for: 0s
|
||||
labels:
|
||||
severity: ticket
|
||||
slo: time-to-ready
|
||||
annotations:
|
||||
summary: Time-to-ready budget is burning slowly
|
||||
runbook: infra/runbooks/queue-lag.md
|
||||
- alert: QueueOldestJobAgeHigh
|
||||
expr: max(messenger_queue_oldest_job_age_seconds) > 120
|
||||
for: 10m
|
||||
labels:
|
||||
severity: warning
|
||||
annotations:
|
||||
summary: The oldest queued/processing job is older than 2 minutes
|
||||
runbook: infra/runbooks/queue-lag.md
|
||||
- alert: QueueOldestJobAgeCritical
|
||||
expr: max(messenger_queue_oldest_job_age_seconds) > 600
|
||||
for: 5m
|
||||
labels:
|
||||
severity: page
|
||||
annotations:
|
||||
summary: The oldest queued/processing job is older than 10 minutes
|
||||
runbook: infra/runbooks/queue-lag.md
|
||||
- alert: QueueDepthGrowing
|
||||
expr: |
|
||||
max(rabbitmq_queue_messages_ready{queue="attachment.process.v1"}) > 20
|
||||
and on() max(deriv(rabbitmq_queue_messages_ready{queue="attachment.process.v1"}[10m])) > 0
|
||||
for: 10m
|
||||
labels:
|
||||
severity: warning
|
||||
annotations:
|
||||
summary: RabbitMQ ready depth is growing
|
||||
runbook: infra/runbooks/queue-lag.md
|
||||
- alert: JobsOverdue
|
||||
expr: max(messenger_jobs_overdue) > 0
|
||||
for: 2m
|
||||
labels:
|
||||
severity: warning
|
||||
slo: time-to-ready
|
||||
annotations:
|
||||
summary: Jobs have been queued/processing for more than 30 seconds
|
||||
runbook: infra/runbooks/queue-lag.md
|
||||
- alert: WorkerSaturated
|
||||
expr: |
|
||||
(sum(messenger_worker_busy) / clamp_min(sum(messenger_worker_capacity), 1) > 0.8)
|
||||
and (max(messenger_queue_oldest_job_age_seconds) > 120)
|
||||
for: 10m
|
||||
labels:
|
||||
severity: warning
|
||||
annotations:
|
||||
summary: Worker slots are saturated while the queue is aging
|
||||
runbook: infra/runbooks/queue-lag.md
|
||||
- alert: DBPoolSaturated
|
||||
expr: |
|
||||
(sum(rate(messenger_db_pool_empty_acquire_total[5m])) > 0)
|
||||
or (sum(messenger_db_pool_used) / clamp_min(sum(messenger_db_pool_max), 1) > 0.8)
|
||||
for: 5m
|
||||
labels:
|
||||
severity: warning
|
||||
annotations:
|
||||
summary: PostgreSQL pool is waiting or nearly exhausted
|
||||
runbook: infra/runbooks/db-availability.md
|
||||
- alert: CollectorDroppedTelemetry
|
||||
expr: |
|
||||
sum(rate(otelcol_exporter_send_failed_spans[5m])) > 0
|
||||
or sum(rate(otelcol_processor_refused_spans[5m])) > 0
|
||||
or sum(rate(otelcol_exporter_send_failed_log_records[5m])) > 0
|
||||
for: 5m
|
||||
labels:
|
||||
severity: warning
|
||||
annotations:
|
||||
summary: Collector is dropping or refusing telemetry
|
||||
runbook: infra/runbooks/telemetry-backend-down.md
|
||||
- alert: TelemetryStorageDown
|
||||
expr: up{job="loki"} == 0
|
||||
for: 2m
|
||||
labels:
|
||||
severity: warning
|
||||
component: telemetry
|
||||
annotations:
|
||||
summary: Loki or Tempo is unavailable; Collector queues are bounded
|
||||
runbook: infra/runbooks/telemetry-backend-down.md
|
||||
- alert: TelemetryCollectorDown
|
||||
expr: up{job="otel-collector"} == 0
|
||||
for: 2m
|
||||
labels:
|
||||
severity: warning
|
||||
component: telemetry
|
||||
annotations:
|
||||
summary: OTel Collector is unavailable; application keeps running
|
||||
runbook: infra/runbooks/telemetry-backend-down.md
|
||||
- alert: APISLIMissing
|
||||
expr: absent(slo:api_error_ratio:5m) or up{job="haproxy"} == 0
|
||||
for: 2m
|
||||
labels:
|
||||
severity: page
|
||||
annotations:
|
||||
summary: Edge availability data is missing
|
||||
runbook: infra/runbooks/api-errors.md
|
||||
- alert: QueueMetricsStale
|
||||
expr: |
|
||||
(absent(messenger_queue_oldest_job_age_seconds) or absent(messenger_jobs_accepted_total))
|
||||
and on() (up{job="otel-collector"} == 1)
|
||||
for: 2m
|
||||
labels:
|
||||
severity: warning
|
||||
annotations:
|
||||
summary: Queue/backlog metrics are missing
|
||||
runbook: infra/runbooks/queue-lag.md
|
||||
@@ -0,0 +1,68 @@
|
||||
groups:
|
||||
- name: slo
|
||||
interval: 5s
|
||||
rules:
|
||||
- record: slo:api_error_ratio:5m
|
||||
expr: |
|
||||
sum(rate(haproxy_frontend_http_responses_total{proxy="http_front",code=~"5.."}[5m]))
|
||||
/
|
||||
clamp_min(sum(rate(haproxy_frontend_http_responses_total{proxy="http_front"}[5m])), 0.001)
|
||||
- record: slo:api_error_ratio:1h
|
||||
expr: |
|
||||
sum(rate(haproxy_frontend_http_responses_total{proxy="http_front",code=~"5.."}[1h]))
|
||||
/
|
||||
clamp_min(sum(rate(haproxy_frontend_http_responses_total{proxy="http_front"}[1h])), 0.001)
|
||||
- record: slo:api_error_ratio:6h
|
||||
expr: |
|
||||
sum(rate(haproxy_frontend_http_responses_total{proxy="http_front",code=~"5.."}[6h]))
|
||||
/
|
||||
clamp_min(sum(rate(haproxy_frontend_http_responses_total{proxy="http_front"}[6h])), 0.001)
|
||||
- record: slo:api_error_ratio:30m
|
||||
expr: |
|
||||
sum(rate(haproxy_frontend_http_responses_total{proxy="http_front",code=~"5.."}[30m]))
|
||||
/
|
||||
clamp_min(sum(rate(haproxy_frontend_http_responses_total{proxy="http_front"}[30m])), 0.001)
|
||||
- record: slo:ttr_bad_ratio:5m
|
||||
expr: |
|
||||
clamp(
|
||||
1 - (
|
||||
sum(rate(messenger_jobs_ready_within_budget_total[5m]))
|
||||
/
|
||||
clamp_min(sum(rate(messenger_jobs_accepted_total[5m])), 0.001)
|
||||
),
|
||||
0, 1
|
||||
)
|
||||
and (sum(rate(messenger_jobs_accepted_total[5m])) > 0)
|
||||
- record: slo:ttr_bad_ratio:1h
|
||||
expr: |
|
||||
clamp(
|
||||
1 - (
|
||||
sum(rate(messenger_jobs_ready_within_budget_total[1h]))
|
||||
/
|
||||
clamp_min(sum(rate(messenger_jobs_accepted_total[1h])), 0.001)
|
||||
),
|
||||
0, 1
|
||||
)
|
||||
and (sum(rate(messenger_jobs_accepted_total[1h])) > 0)
|
||||
- record: slo:ttr_bad_ratio:6h
|
||||
expr: |
|
||||
clamp(
|
||||
1 - (
|
||||
sum(rate(messenger_jobs_ready_within_budget_total[6h]))
|
||||
/
|
||||
clamp_min(sum(rate(messenger_jobs_accepted_total[6h])), 0.001)
|
||||
),
|
||||
0, 1
|
||||
)
|
||||
and (sum(rate(messenger_jobs_accepted_total[6h])) > 0)
|
||||
- record: slo:ttr_bad_ratio:30m
|
||||
expr: |
|
||||
clamp(
|
||||
1 - (
|
||||
sum(rate(messenger_jobs_ready_within_budget_total[30m]))
|
||||
/
|
||||
clamp_min(sum(rate(messenger_jobs_accepted_total[30m])), 0.001)
|
||||
),
|
||||
0, 1
|
||||
)
|
||||
and (sum(rate(messenger_jobs_accepted_total[30m])) > 0)
|
||||
@@ -0,0 +1,3 @@
|
||||
# Per-queue Prometheus series: the default exporter aggregates queues, but the
|
||||
# lab dashboard and oldest/queue-depth alert need the queue label.
|
||||
prometheus.return_per_object_metrics = true
|
||||
@@ -0,0 +1,8 @@
|
||||
# API error / availability SLI
|
||||
|
||||
1. Grafana → Lab6 → API overview. Check `slo:api_error_ratio:5m` and the edge panel; 5xx at HAProxy is the SLI, API-side 5xx is diagnostic.
|
||||
2. Prometheus → Status → Targets: `haproxy`, `otel-collector`, `rabbitmq` must be UP. If HAProxy is DOWN, no edge SLI exists; inspect `docker compose ps lb`.
|
||||
3. HAProxy stats `http://127.0.0.1:8404/stats`: look for DOWN replicas and `check` errors. A stale `X-Instance-Id` is the stopped replica.
|
||||
4. If all replicas are DOWN, check `/health/ready` of one replica (5xx means DB/S3 dependency) and PostgreSQL logs.
|
||||
5. For a slow handler, open a Tempo trace from the error panel; DB child span (`SELECT`/`INSERT`/`UPDATE`/`BEGIN`/`COMMIT`) duration vs HTTP span shows whether PostgreSQL or the handler is slow. Correlate `trace_id` in Loki.
|
||||
6. Recover DB/S3, wait for HAProxy `rise 2`, then verify a 2xx through the LB and resolved alert.
|
||||
@@ -0,0 +1,8 @@
|
||||
# PostgreSQL slow/unavailable
|
||||
|
||||
1. Edge SLI first: HAProxy may return 503/504 while API replicas are removed by `/health/ready`; API-side 5xx can therefore be near zero. Use the HAProxy panel and `up{job="haproxy"}`.
|
||||
2. `docker compose ps postgres`; `docker compose logs --tail=100 postgres`; `pg_isready` from a replica.
|
||||
3. Prometheus: `messenger_db_pool_used/idle/max`, `messenger_db_pool_empty_acquire_total`, `rate(...wait_seconds)`; API/worker DB spans in Tempo (`SELECT`/`INSERT`/`UPDATE`/`BEGIN`/`COMMIT`, `pool.acquire`) show failures/latency.
|
||||
4. Loki: `{service_name=~"messenger-api|messenger-worker"} | severity_text="error" | trace_id="<id>"`. A handler span with a long DB child span is a DB problem; a long handler without a DB child is an application problem.
|
||||
5. If PostgreSQL was stopped, start it, wait for health, then let the pool reconnect. Worker deliveries are requeued; verify no accepted job is lost (jobs accepted/ready/failed counts).
|
||||
6. Confirm the alert resolved; record injection/restore and first successful request timestamps.
|
||||
@@ -0,0 +1,8 @@
|
||||
# Queue lag / time-to-ready
|
||||
|
||||
1. Grafana → Lab6 → Jobs and queue: `messenger_queue_oldest_job_age_seconds`, `rabbitmq_queue_messages_ready`, `messenger_worker_busy/capacity`, TTR p95.
|
||||
2. If oldest age grows and `worker_busy == capacity`, the worker is saturated: inspect `worker` logs (`job claimed`, `job retry scheduled`) and `WORKER_CONCURRENCY`.
|
||||
3. If queue depth grows but `worker_busy == 0`, the worker is stopped or cannot connect to the broker: `docker compose ps worker`, worker `/health/ready`, broker `rabbitmqctl list_queues`.
|
||||
4. If retries grow, filter Loki `{service_name="messenger-worker"} | severity_text="error"` and trace `job.process` attempts; check `error_code`.
|
||||
5. For a lost delivery, relay logs `outbox publish cycle` / `lost queued jobs reconciled` and `jobctl failed`.
|
||||
6. Restore worker/broker, verify queue depth < 5 and oldest age < 5s for two scrapes, then confirm the alert resolved.
|
||||
@@ -0,0 +1,15 @@
|
||||
# SLO burn-rate
|
||||
|
||||
1. Open Grafana → Lab6 → API overview and Jobs and queue.
|
||||
2. Check `slo:api_error_ratio:1h` + `5m` for fast burn, `6h` + `30m`
|
||||
for slow burn; TTR uses `slo:ttr_bad_ratio:*`.
|
||||
3. Fast page means the current hour is consuming the 7-day error budget at
|
||||
≥14.4×. Confirm edge traffic in HAProxy (`proxy="http_front"`), then inspect
|
||||
API traces for 5xx and DB spans (`SELECT`/`INSERT`/`UPDATE`/`BEGIN`/`COMMIT`)
|
||||
or missing worker `job.process` spans.
|
||||
4. Slow ticket means a sustained 6-hour burn. It can fire with a low current
|
||||
rate; do not suppress it until the 30m window is below 3% (API) or 6% (TTR).
|
||||
5. Resolve only after the SLO ratio stays below the fast/slow thresholds and
|
||||
the underlying dependency (worker, PostgreSQL, broker) is healthy.
|
||||
6. Record injection/restore UTC and the first firing/resolved timestamps in
|
||||
`evidence/lab6/track2/`.
|
||||
@@ -0,0 +1,8 @@
|
||||
# Telemetry backend down
|
||||
|
||||
1. This is an observability incident, not a business outage. First verify API: `curl -fsS http://127.0.0.1:8080/health/ready` and a smoke request.
|
||||
2. `docker compose ps otel-collector prometheus loki tempo grafana`.
|
||||
3. If Tempo/Loki is down, Collector exporter queues fill; inspect `otelcol_exporter_queue_size`, `otelcol_exporter_send_failed_*`, `otelcol_processor_refused_*`. Queues are bounded by `sizer: bytes`; the Collector does not grow without limit.
|
||||
4. If the Collector is down, Prometheus `up{job="otel-collector"}=0`; the application continues to accept work. Application OTLP export failures are best-effort and do not affect `/health/ready`.
|
||||
5. Restart the failed backend/collector; confirm `up`, queue drains, and no new refused records. Lost telemetry is bounded and documented; business data in PostgreSQL/S3 is unaffected.
|
||||
6. Do not stop Prometheus while diagnosing another alert: without Prometheus there is no rule evaluation. Use HAProxy stats and container logs as fallback.
|
||||
@@ -0,0 +1,27 @@
|
||||
server:
|
||||
http_listen_port: 3200
|
||||
grpc_listen_port: 9095
|
||||
|
||||
distributor:
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
grpc:
|
||||
endpoint: 0.0.0.0:4317
|
||||
http:
|
||||
endpoint: 0.0.0.0:4318
|
||||
|
||||
storage:
|
||||
trace:
|
||||
backend: local
|
||||
local:
|
||||
path: /var/tempo/traces
|
||||
wal:
|
||||
path: /var/tempo/wal
|
||||
|
||||
compactor:
|
||||
compaction:
|
||||
block_retention: 72h
|
||||
|
||||
usage_report:
|
||||
reporting_enabled: false
|
||||
Reference in New Issue
Block a user