Files
mtusi2026lab7-safronov/infra/otel/collector.yaml
T
ricoromaandClaude Opus 5.5 089d78609d chore: port lab 6 solution into the lab 7 skeleton
Source: mtusi2026lab6-safronov, solution/bvt2301-safronov, 6c6a065.
Files follow AGENTS.md, "Переход в следующую лабу". Contracts, public
tests, README, REPORT and evidence of lab 6 are not carried over; infra
and scripts of the lab 7 skeleton stay as they are.
Makefile is the lab 6 one with the lab 7 skeleton part restored
(HTTPS BASE_URL on 8443, test-security); .gitignore and .dockerignore
are taken from lab 6 because both skeletons have the same files;
.env.example is the lab 6 one without changes.
The compose project, image and CI prefix are renamed to lab7, and
references to the previous lab now name lab6.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-16 03:59:04 +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]