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,612 @@
|
||||
{
|
||||
"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(http_server_request_duration_seconds_count[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 (missed / (within 30s + missed))",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 14
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "slo:job_ttr_bad_ratio:5m",
|
||||
"legendFormat": "5m",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "slo:job_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": {}
|
||||
},
|
||||
{
|
||||
"id": 14,
|
||||
"type": "stat",
|
||||
"title": "API error budget remaining (7d)",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "slo:api_budget_remaining:7d",
|
||||
"refId": "A",
|
||||
"legendFormat": "remaining"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percentunit",
|
||||
"min": 0,
|
||||
"max": 1
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 6,
|
||||
"w": 6,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"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,452 @@
|
||||
{
|
||||
"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(http_server_request_duration_seconds_count[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": "none"
|
||||
},
|
||||
"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": "none"
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"matcher": {
|
||||
"id": "byFrameRefID",
|
||||
"options": "A"
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"id": "unit",
|
||||
"value": "ops"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"matcher": {
|
||||
"id": "byFrameRefID",
|
||||
"options": "B"
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
"id": "unit",
|
||||
"value": "s"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"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": "bytes"
|
||||
},
|
||||
"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": "none"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"options": {}
|
||||
},
|
||||
{
|
||||
"id": 33,
|
||||
"type": "timeseries",
|
||||
"title": "Process CPU by service",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "sum by (service_name) (rate(messenger_process_cpu_seconds_total[5m]))",
|
||||
"refId": "A",
|
||||
"legendFormat": "{{service_name}}"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "cores"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 34,
|
||||
"type": "timeseries",
|
||||
"title": "Process memory vs limit",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "sum by (service_name) (messenger_process_memory_usage_bytes) / clamp_min(sum by (service_name) (messenger_process_memory_limit_bytes), 1)",
|
||||
"refId": "A",
|
||||
"legendFormat": "{{service_name}}"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "percentunit"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 35,
|
||||
"type": "timeseries",
|
||||
"title": "RPS by route and status",
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"expr": "sum by (http_route,http_response_status_class) (rate(http_server_request_duration_seconds_count[5m]))",
|
||||
"refId": "A",
|
||||
"legendFormat": "{{http_route}} {{http_response_status_code}}"
|
||||
}
|
||||
],
|
||||
"fieldConfig": {
|
||||
"defaults": {
|
||||
"unit": "reqps"
|
||||
},
|
||||
"overrides": []
|
||||
},
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 0,
|
||||
"y": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"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 (missed / (within 30s + missed))",
|
||||
"type": "timeseries",
|
||||
"gridPos": {
|
||||
"h": 7,
|
||||
"w": 12,
|
||||
"x": 12,
|
||||
"y": 14
|
||||
},
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "slo:job_ttr_bad_ratio:5m",
|
||||
"legendFormat": "5m",
|
||||
"refId": "A",
|
||||
"range": true
|
||||
},
|
||||
{
|
||||
"datasource": {
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "slo:job_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:
|
||||
tracesToLogsV2:
|
||||
datasourceUid: loki
|
||||
filterByTraceID: true
|
||||
filterBySpanID: false
|
||||
tags:
|
||||
- key: service.name
|
||||
value: service_name
|
||||
@@ -0,0 +1,92 @@
|
||||
# Load balancer for the lab3 stand (HAProxy, container `lb`).
|
||||
#
|
||||
# Почему активные проверки, а не пассивные: nginx OSS умел только пассивные, и
|
||||
# реплика, которая осталась доступной по сети, но потеряла БД, продолжала получать
|
||||
# трафик и отвечала 503 (измерено: 20 из 40 запросов /health/live). HAProxy сам
|
||||
# опрашивает /health/ready и полностью убирает неготовую реплику из ротации.
|
||||
#
|
||||
# Почему повторы безопасны: `retry-on conn-failure` — повтор только когда
|
||||
# соединение не установилось и запрос НЕ ушёл. Если запрос уже передан серверу,
|
||||
# повтора нет, поэтому прозрачного дублирования POST (создание чата, сообщения)
|
||||
# балансировщик не делает. Неопределённый результат повторяет клиент, а сообщение
|
||||
# защищено обязательным Idempotency-Key (контракт 1.3.0).
|
||||
|
||||
global
|
||||
log stdout format raw local0
|
||||
maxconn 2048
|
||||
|
||||
defaults
|
||||
mode http
|
||||
log global
|
||||
log-format "%ST %Tt %b"
|
||||
option dontlognull
|
||||
timeout connect 1s
|
||||
timeout client 70s
|
||||
timeout server 45s
|
||||
# Проверка готовности: одна проба не может висеть дольше 1 с, поэтому при
|
||||
# inter 2s fall 2 реплика уходит из ротации максимум за ~4 с, даже если она
|
||||
# держит соединение открытым и не отвечает.
|
||||
#
|
||||
# timeout server увеличен для 10 MiB загрузок: spool + S3 Put не всегда
|
||||
# укладываются в прежние 5 с под конкурентной нагрузкой. Readiness-проба
|
||||
# остаётся с timeout check 1s, поэтому обнаружение мёртвой реплики не
|
||||
# замедляется.
|
||||
timeout check 1s
|
||||
retry-on conn-failure
|
||||
retries 2
|
||||
option redispatch
|
||||
|
||||
resolvers docker
|
||||
nameserver dns 127.0.0.11:53
|
||||
resolve_retries 3
|
||||
timeout resolve 1s
|
||||
timeout retry 1s
|
||||
hold valid 5s
|
||||
hold nx 2s
|
||||
hold timeout 1s
|
||||
hold refused 1s
|
||||
hold obsolete 5s
|
||||
|
||||
backend api_backend
|
||||
balance leastconn
|
||||
# Период проверки 2 с; реплика исключается после 2 неудач (<=4 с) и
|
||||
# возвращается в ротацию после 2 успехов (<=4 с).
|
||||
option httpchk
|
||||
http-check send meth GET uri /health/ready
|
||||
http-check expect status 200
|
||||
# Одно имя -> все адреса реплик (общий network alias в compose.yaml),
|
||||
# адреса переразрешаются каждые 5 с: масштабирование и замена контейнеров
|
||||
# не зависят от их номеров и IP.
|
||||
default-server check inter 2s fall 2 rise 2 resolvers docker resolve-prefer ipv4 init-addr none
|
||||
# Слотов больше, чем типовых реплик (1/2/4 в треке 1): свободный слот нужен
|
||||
# ещё и сценарию scripts/lb_readiness_check.sh, который поднимает рядом
|
||||
# «неготовую» реплику.
|
||||
server-template api 8 api-replica:8080
|
||||
|
||||
backend api_health
|
||||
balance leastconn
|
||||
# Dedicated backend for client readiness/liveness endpoints. Keeping it
|
||||
# separate keeps /health traffic out of the API availability SLI.
|
||||
option httpchk
|
||||
http-check send meth GET uri /health/ready
|
||||
http-check expect status 200
|
||||
default-server check inter 2s fall 2 rise 2 resolvers docker resolve-prefer ipv4 init-addr none
|
||||
server-template api 8 api-replica:8080
|
||||
|
||||
frontend http_front
|
||||
bind *:80
|
||||
use_backend api_health if { path_beg /health/ }
|
||||
default_backend api_backend
|
||||
|
||||
frontend stats_front
|
||||
# Только для оператора и доказательств: видно, какие реплики UP/DOWN и почему.
|
||||
bind *:8404
|
||||
# Built-in Prometheus exporter (HAProxy built with USE_PROMEX). The edge
|
||||
# SLI uses backend api_backend; /health/* is routed to api_health and is not
|
||||
# part of the availability numerator or denominator.
|
||||
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,28 @@
|
||||
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"]
|
||||
- job_name: tempo
|
||||
metrics_path: /metrics
|
||||
static_configs:
|
||||
- targets: ["tempo:3200"]
|
||||
@@ -0,0 +1,160 @@
|
||||
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_backend_http_responses_total{proxy="api_backend"}[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_backend_http_responses_total{proxy="api_backend"}[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:job_ttr_bad_ratio:1h > 0.144 and slo:job_ttr_bad_ratio:5m > 0.144 and on() (sum(increase(messenger_job_time_to_ready_seconds_bucket{le="30.0"}[5m])) or vector(0)) + (sum(increase(messenger_jobs_ttr_missed_total[5m])) or vector(0)) >= 10
|
||||
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:job_ttr_bad_ratio:6h > 0.06 and slo:job_ttr_bad_ratio:30m > 0.06 and on() (sum(increase(messenger_job_time_to_ready_seconds_bucket{le="30.0"}[30m])) or vector(0)) + (sum(increase(messenger_jobs_ttr_missed_total[30m])) or vector(0)) >= 30
|
||||
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_wait_seconds_total[5m]))
|
||||
/
|
||||
clamp_min(sum(rate(messenger_db_pool_empty_acquire_total[5m])), 1e-9)
|
||||
> 0.05
|
||||
)
|
||||
and (sum(rate(messenger_db_pool_empty_acquire_total[5m])) > 0.1)
|
||||
)
|
||||
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_receiver_failed_spans[5m])) > 0
|
||||
or sum(rate(otelcol_receiver_failed_metric_points[5m])) > 0
|
||||
or sum(rate(otelcol_receiver_failed_log_records[5m])) > 0
|
||||
or sum(rate(otelcol_receiver_refused_spans[5m])) > 0
|
||||
or sum(rate(otelcol_receiver_refused_metric_points[5m])) > 0
|
||||
or sum(rate(otelcol_receiver_refused_log_records[5m])) > 0
|
||||
or sum(rate(otelcol_exporter_send_failed_spans[5m])) > 0
|
||||
or sum(rate(otelcol_exporter_send_failed_log_records[5m])) > 0
|
||||
or sum(rate(otelcol_exporter_send_failed_metric_points[5m])) > 0
|
||||
or sum(rate(otelcol_exporter_enqueue_failed_spans[5m])) > 0
|
||||
or sum(rate(otelcol_exporter_enqueue_failed_log_records[5m])) > 0
|
||||
or sum(rate(otelcol_exporter_enqueue_failed_metric_points[5m])) > 0
|
||||
or sum(otelcol_exporter_queue_size) >= sum(otelcol_exporter_queue_capacity) * 0.9
|
||||
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|tempo"} == 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,95 @@
|
||||
groups:
|
||||
- name: slo
|
||||
interval: 5s
|
||||
rules:
|
||||
- record: slo:api_error_ratio:5m
|
||||
expr: |
|
||||
sum(rate(haproxy_backend_http_responses_total{proxy="api_backend",code=~"5.."}[5m]))
|
||||
/
|
||||
clamp_min(sum(rate(haproxy_backend_http_responses_total{proxy="api_backend"}[5m])), 0.001)
|
||||
- record: slo:api_error_ratio:1h
|
||||
expr: |
|
||||
sum(rate(haproxy_backend_http_responses_total{proxy="api_backend",code=~"5.."}[1h]))
|
||||
/
|
||||
clamp_min(sum(rate(haproxy_backend_http_responses_total{proxy="api_backend"}[1h])), 0.001)
|
||||
- record: slo:api_error_ratio:6h
|
||||
expr: |
|
||||
sum(rate(haproxy_backend_http_responses_total{proxy="api_backend",code=~"5.."}[6h]))
|
||||
/
|
||||
clamp_min(sum(rate(haproxy_backend_http_responses_total{proxy="api_backend"}[6h])), 0.001)
|
||||
- record: slo:api_error_ratio:30m
|
||||
expr: |
|
||||
sum(rate(haproxy_backend_http_responses_total{proxy="api_backend",code=~"5.."}[30m]))
|
||||
/
|
||||
clamp_min(sum(rate(haproxy_backend_http_responses_total{proxy="api_backend"}[30m])), 0.001)
|
||||
- record: slo:job_ttr_bad_ratio:5m
|
||||
expr: |
|
||||
(
|
||||
(sum(rate(messenger_jobs_ttr_missed_total[5m])) or vector(0))
|
||||
/
|
||||
clamp_min(
|
||||
(sum(rate(messenger_job_time_to_ready_seconds_bucket{le="30.0"}[5m])) or vector(0))
|
||||
+ (sum(rate(messenger_jobs_ttr_missed_total[5m])) or vector(0)),
|
||||
0.001
|
||||
)
|
||||
)
|
||||
and on() (
|
||||
(sum(increase(messenger_job_time_to_ready_seconds_bucket{le="30.0"}[5m])) or vector(0))
|
||||
+ (sum(increase(messenger_jobs_ttr_missed_total[5m])) or vector(0))
|
||||
) >= 10
|
||||
- record: slo:job_ttr_bad_ratio:1h
|
||||
expr: |
|
||||
(
|
||||
(sum(rate(messenger_jobs_ttr_missed_total[1h])) or vector(0))
|
||||
/
|
||||
clamp_min(
|
||||
(sum(rate(messenger_job_time_to_ready_seconds_bucket{le="30.0"}[1h])) or vector(0))
|
||||
+ (sum(rate(messenger_jobs_ttr_missed_total[1h])) or vector(0)),
|
||||
0.001
|
||||
)
|
||||
)
|
||||
and on() (
|
||||
(sum(increase(messenger_job_time_to_ready_seconds_bucket{le="30.0"}[1h])) or vector(0))
|
||||
+ (sum(increase(messenger_jobs_ttr_missed_total[1h])) or vector(0))
|
||||
) >= 10
|
||||
- record: slo:job_ttr_bad_ratio:6h
|
||||
expr: |
|
||||
(
|
||||
(sum(rate(messenger_jobs_ttr_missed_total[6h])) or vector(0))
|
||||
/
|
||||
clamp_min(
|
||||
(sum(rate(messenger_job_time_to_ready_seconds_bucket{le="30.0"}[6h])) or vector(0))
|
||||
+ (sum(rate(messenger_jobs_ttr_missed_total[6h])) or vector(0)),
|
||||
0.001
|
||||
)
|
||||
)
|
||||
and on() (
|
||||
(sum(increase(messenger_job_time_to_ready_seconds_bucket{le="30.0"}[6h])) or vector(0))
|
||||
+ (sum(increase(messenger_jobs_ttr_missed_total[6h])) or vector(0))
|
||||
) >= 30
|
||||
- record: slo:job_ttr_bad_ratio:30m
|
||||
expr: |
|
||||
(
|
||||
(sum(rate(messenger_jobs_ttr_missed_total[30m])) or vector(0))
|
||||
/
|
||||
clamp_min(
|
||||
(sum(rate(messenger_job_time_to_ready_seconds_bucket{le="30.0"}[30m])) or vector(0))
|
||||
+ (sum(rate(messenger_jobs_ttr_missed_total[30m])) or vector(0)),
|
||||
0.001
|
||||
)
|
||||
)
|
||||
and on() (
|
||||
(sum(increase(messenger_job_time_to_ready_seconds_bucket{le="30.0"}[30m])) or vector(0))
|
||||
+ (sum(increase(messenger_jobs_ttr_missed_total[30m])) or vector(0))
|
||||
) >= 30
|
||||
|
||||
- name: slo-long
|
||||
interval: 1m
|
||||
rules:
|
||||
- record: slo:api_error_ratio:7d
|
||||
expr: |
|
||||
sum(rate(haproxy_backend_http_responses_total{proxy="api_backend",code=~"5.."}[7d]))
|
||||
/
|
||||
clamp_min(sum(rate(haproxy_backend_http_responses_total{proxy="api_backend"}[7d])), 0.001)
|
||||
- record: slo:api_budget_remaining:7d
|
||||
expr: clamp(1 - (slo:api_error_ratio:7d / 0.005), 0, 1)
|
||||
@@ -0,0 +1,65 @@
|
||||
rule_files:
|
||||
- ../rules/slo.yml
|
||||
- ../rules/alerts.yml
|
||||
evaluation_interval: 1m
|
||||
tests:
|
||||
- interval: 1m
|
||||
input_series:
|
||||
- series: 'messenger_job_time_to_ready_seconds_bucket{le="30.0"}'
|
||||
values: '0+10x10'
|
||||
- series: 'messenger_job_time_to_ready_seconds_count'
|
||||
values: '0+10x10'
|
||||
promql_expr_test:
|
||||
- expr: slo:job_ttr_bad_ratio:5m
|
||||
eval_time: 5m
|
||||
exp_samples:
|
||||
- labels: '{__name__="slo:job_ttr_bad_ratio:5m"}'
|
||||
value: 0
|
||||
- interval: 1m
|
||||
input_series:
|
||||
- series: 'messenger_jobs_ttr_missed_total'
|
||||
values: '0+10x10'
|
||||
promql_expr_test:
|
||||
- expr: slo:job_ttr_bad_ratio:5m
|
||||
eval_time: 5m
|
||||
exp_samples:
|
||||
- labels: '{__name__="slo:job_ttr_bad_ratio:5m"}'
|
||||
value: 1
|
||||
- interval: 1m
|
||||
input_series:
|
||||
- series: 'messenger_job_time_to_ready_seconds_bucket{le="30.0"}'
|
||||
values: '10+0x5 stale'
|
||||
- series: 'messenger_job_time_to_ready_seconds_count'
|
||||
values: '10+0x5 stale'
|
||||
- series: 'messenger_jobs_ttr_missed_total'
|
||||
values: '0+10x20'
|
||||
promql_expr_test:
|
||||
- expr: slo:job_ttr_bad_ratio:5m
|
||||
eval_time: 15m
|
||||
exp_samples:
|
||||
- labels: '{__name__="slo:job_ttr_bad_ratio:5m"}'
|
||||
value: 1
|
||||
- interval: 1m
|
||||
input_series:
|
||||
- series: 'messenger_job_time_to_ready_seconds_bucket{le="30.0"}'
|
||||
values: '0+5x10'
|
||||
- series: 'messenger_job_time_to_ready_seconds_count'
|
||||
values: '0+10x10'
|
||||
- series: 'messenger_jobs_ttr_missed_total'
|
||||
values: '0+2x10'
|
||||
promql_expr_test:
|
||||
- expr: slo:job_ttr_bad_ratio:5m
|
||||
eval_time: 5m
|
||||
exp_samples:
|
||||
- labels: '{__name__="slo:job_ttr_bad_ratio:5m"}'
|
||||
value: 0.2857142857142857
|
||||
- interval: 1m
|
||||
input_series:
|
||||
- series: 'messenger_job_time_to_ready_seconds_bucket{le="30.0"}'
|
||||
values: '0x10'
|
||||
- series: 'messenger_jobs_ttr_missed_total'
|
||||
values: '0 6 6 6 6 6 6 6 6 6 6'
|
||||
alert_rule_test:
|
||||
- eval_time: 5m
|
||||
alertname: TTRErrorBudgetFastBurn
|
||||
exp_alerts: []
|
||||
@@ -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:job_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="api_backend"`), 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 @@
|
||||
# SeaweedFS identities
|
||||
|
||||
`infra/s3/s3.json` is mounted read-only into the `seaweedfs` container and is
|
||||
the single source of truth for S3 credentials and permissions.
|
||||
|
||||
- `admin` is used only by the one-shot `s3-init` service (bucket creation and
|
||||
probing). It is never given to the API and must not be placed in `.env`:
|
||||
the API service loads `.env` as an environment file. Compose supplies the
|
||||
synthetic admin values to `s3-init` directly.
|
||||
- `app` is used by the API and by presigned uploads. It can read/write only
|
||||
`messenger-attachments/attachments/*` and `messenger-attachments/staging/*`,
|
||||
and list the bucket for the orphan sweeper.
|
||||
|
||||
The credentials are synthetic values for the local stand. `.env.example`
|
||||
carries the same values for the API and `scripts/check_s3_creds.py` fails the
|
||||
offline check if they drift. Replace them in `.env` for any non-local run.
|
||||
|
||||
Verify manually:
|
||||
|
||||
```sh
|
||||
# anonymous requests are denied
|
||||
docker compose exec -T seaweedfs \
|
||||
wget -qO- http://127.0.0.1:8333/messenger-attachments/attachments/missing
|
||||
|
||||
# the app identity cannot write outside its prefixes
|
||||
docker compose run --rm s3-init # probes this and exits non-zero on violation
|
||||
```
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"identities": [
|
||||
{
|
||||
"name": "admin",
|
||||
"credentials": [
|
||||
{"accessKey": "lab4admin", "secretKey": "lab4admin-secret"}
|
||||
],
|
||||
"actions": ["Admin", "Read", "Write", "List", "Tagging"]
|
||||
},
|
||||
{
|
||||
"name": "app",
|
||||
"credentials": [
|
||||
{"accessKey": "lab4app", "secretKey": "lab4app-secret"}
|
||||
],
|
||||
"actions": [
|
||||
"Read:messenger-attachments/attachments/*",
|
||||
"Write:messenger-attachments/attachments/*",
|
||||
"Read:messenger-attachments/staging/*",
|
||||
"Write:messenger-attachments/staging/*",
|
||||
"List:messenger-attachments"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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