lab6: observability — OTel Collector, Prometheus, Loki, Tempo, Grafana

This commit is contained in:
2026-11-13 13:20:46 +03:00
parent 470d9d6f1e
commit 5945e035e0
63 changed files with 6436 additions and 19 deletions
+43
View File
@@ -0,0 +1,43 @@
global:
scrape_interval: 15s
evaluation_interval: 15s
external_labels:
cluster: mtusi-lab6
rule_files:
- /etc/prometheus/rules/*.yml
scrape_configs:
- job_name: prometheus
static_configs:
- targets: ["localhost:9090"]
- job_name: otel-collector
static_configs:
- targets: ["otel-collector:8888"]
# API — обе реплики (хардкод имён контейнеров; в compose алиасы сервисов
# не работают для обеих реплик одновременно через DNS SD)
- job_name: api
metrics_path: /metrics
static_configs:
- targets:
- "mtusi2026lab6-api-1:8080"
- "mtusi2026lab6-api-2:8080"
labels:
service: api
- job_name: worker
metrics_path: /metrics
static_configs:
- targets: ["worker:9100"]
- job_name: relay
metrics_path: /metrics
static_configs:
- targets: ["relay:9101"]
- job_name: rabbitmq
metrics_path: /metrics
static_configs:
- targets: ["broker:15692"]
@@ -0,0 +1,33 @@
groups:
- name: api
interval: 30s
rules:
- alert: HighErrorRate
expr: |
(
sum(rate(http_requests_total{status_class="5xx"}[5m]))
/
sum(rate(http_requests_total[5m]))
) > 0.05
for: 2m
labels:
severity: warning
component: api
annotations:
summary: "API 5xx ratio > 5% for 2m"
description: "Current 5xx ratio: {{ $value | humanizePercentage }}"
runbook: "infra/otel/runbooks/high-error-rate.md"
- alert: HighLatency
expr: |
histogram_quantile(
0.95,
sum(rate(http_request_duration_seconds_bucket[5m])) by (le)
) > 2.0
for: 5m
labels:
severity: warning
component: api
annotations:
summary: "API p95 latency > 2s for 5m"
description: "p95 latency: {{ $value | humanizeDuration }}"
@@ -0,0 +1,26 @@
groups:
- name: worker
interval: 30s
rules:
- alert: QueueLagHigh
expr: |
jobs_oldest_pending_age_seconds > 60
for: 2m
labels:
severity: critical
component: worker
annotations:
summary: "Oldest pending job age > 60s for 2m"
description: "Oldest pending job: {{ $value | humanizeDuration }}"
runbook: "infra/otel/runbooks/queue-lag.md"
- alert: WorkerSaturated
expr: |
worker_in_flight >= worker_capacity
for: 5m
labels:
severity: warning
component: worker
annotations:
summary: "Worker at capacity for 5m"
description: "in_flight={{ $value }}"