Files
mtusi2026lab6/infra/otel/collector.yaml
T
ricoromaandClaude Opus 5.5 15ea156404 feat: add SLOs, Prometheus alert rules and telemetry loss accounting
HAProxy /metrics scraped by the Collector, recording rules and seven alerts with promtool tests and runbooks (make alerts_test, CI step), byte-sized Collector export queues with 30 s retries, SDK internal metrics, SLO/LB/pipeline dashboard rows, driver commands alerts-check and backend-outage (change slo-alerts).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 00:35:01 +03:00

135 lines
6.4 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# OTel Collector contrib 0.164.0 (design change otel-telemetry, решения 1, 3,
# 14): получатель, обработчик и экспортёр, не хранилище. Три pipeline — каждый
# до своего хранилища: метрики — scrape Prometheus с экспортёра prometheus,
# логи — Loki (родной OTLP), трассы — Tempo. Расширений нет (pprof, zpages,
# health_check образа не берутся). Порты наружу не публикуются: OTLP
# слушает сеть приложения, :8888 и :8889 забирает Prometheus в сети
# telemetry. Буферизация, повторы, метрики LB и срок рядов — design change
# slo-alerts, решения 2, 6, 7.
receivers:
otlp:
protocols:
# только OTLP/HTTP: SDK приложения отправляет protobuf по HTTP
http:
endpoint: 0.0.0.0:4318
# метрики LB (решение 2): встроенный экспортёр HAProxy на порту статистики
# в сети приложения. LB не входит в сеть хранилищ, Prometheus — в сеть
# приложения: метрики идут через Collector, как метрики API. Только уровни
# frontend и backend (без рядов по слотам и адресов реплик) и отобранные
# имена; на экспортёре — job = haproxy, instance = haproxy:8404, плюс up
prometheus/haproxy:
config:
scrape_configs:
- job_name: haproxy
scrape_interval: 15s
scrape_timeout: 10s
metrics_path: /metrics
params:
scope: [frontend, backend]
static_configs:
- targets: ["haproxy:8404"]
metric_relabel_configs:
- source_labels: [__name__]
action: keep
regex: haproxy_(frontend_http_requests_total|frontend_http_responses_total|backend_http_responses_total|backend_active_servers|backend_connection_errors_total|backend_response_errors_total|backend_retry_warnings_total|backend_redispatch_warnings_total)
processors:
# предел памяти Collector: при 200 МиБ отказ приёма (SDK получает ошибку и
# теряет пакет, otelcol_receiver_refused_*), всплеск — 40 МиБ; GOMEMLIMIT
# контейнера — 160 МиБ. Худший случай очередей экспорта (обе полны, 24 МиБ
# protobuf ≈ 50–75 МиБ в памяти) + основа ~50 МиБ — ниже мягкого предела
memory_limiter:
check_interval: 1s
limit_mib: 200
spike_limit_mib: 40
# пакеты трасс и метрик: не больше 1024 элементов или раз в секунду; пакет
# span (≤ 1 МиБ) меньше очереди экспорта Tempo — больший отклоняется целиком
batch:
send_batch_size: 1024
send_batch_max_size: 1024
timeout: 1s
# пакеты журнала — не больше 256 записей: запись до 32 КиБ (traceback), и
# пакет (≤ 8 МиБ) всегда помещается в очередь экспорта Loki (16 МиБ)
batch/logs:
send_batch_size: 256
send_batch_max_size: 256
timeout: 1s
exporters:
# метрики приложения для scrape Prometheus (honor_labels): job =
# service.name, instance = service.instance.id, остальной ресурс —
# target_info. Ряд, не обновлявшийся минуту (четыре интервала отправки SDK
# 15 с), уходит (решение 6): у процесса, запущенного позже, время начала
# ряда новее последней точки, и Prometheus пишет ноль — increase() видит и
# сброс, и первые события; снимок очереди остановленного relay уходит через
# ≤ 75 с, а не 5 мин
prometheus:
endpoint: 0.0.0.0:8889
translation_strategy: UnderscoreEscapingWithSuffixes
metric_expiration: 1m
resource_to_telemetry_conversion:
enabled: false
# очередь в памяти с пределом в байтах и повторы с пределом времени
# (решение 7): полная очередь отклоняет новое (enqueue_failed), не задерживая
# приём; пакет с истёкшими 30 с повторов отбрасывается (send_failed).
# Рестарт хранилища на стенде — 5–15 с: короткий отказ потерь не даёт
otlp_http/loki:
endpoint: http://loki:3100/otlp
timeout: 5s
sending_queue:
enabled: true
num_consumers: 2
sizer: bytes
# 16 МиБ записей — ~40–90 с пика (379 записей/с)
queue_size: 16777216
block_on_overflow: false
retry_on_failure:
enabled: true
initial_interval: 1s
max_interval: 5s
max_elapsed_time: 30s
otlp_http/tempo:
endpoint: http://tempo:4318
timeout: 5s
sending_queue:
enabled: true
num_consumers: 2
sizer: bytes
# 8 МиБ span — ~10–15 с пика (1127 span/с) и минуты обычного трафика
queue_size: 8388608
block_on_overflow: false
retry_on_failure:
enabled: true
initial_interval: 1s
max_interval: 5s
max_elapsed_time: 30s
service:
telemetry:
logs:
level: info
encoding: json
# собственные метрики Collector — для Prometheus (жив ли конвейер, очереди
# экспорта и потери: otelcol_exporter_*, otelcol_receiver_refused_*)
metrics:
level: normal
readers:
- pull:
exporter:
prometheus:
host: 0.0.0.0
port: 8888
pipelines:
metrics:
receivers: [otlp, prometheus/haproxy]
processors: [memory_limiter, batch]
exporters: [prometheus]
logs:
receivers: [otlp]
processors: [memory_limiter, batch/logs]
exporters: [otlp_http/loki]
traces:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [otlp_http/tempo]