# LAB 6: OTel Collector — приёмник/обработчик/экспортёр, НЕ долговременная БД. # # Схема: API/worker --OTLP/HTTP--> receivers.otlp # -> memory_limiter (жёсткий потолок RAM) # -> resource (нормализация/очистка атрибутов) # -> batch (ограниченная буферизация) # -> exporters: Prometheus (метрики, pull), Loki (логи, OTLP), Tempo (трассы, OTLP) # # Уровень 4: при недоступном backend очередь ОГРАНИЧЕНА (queue_size), # retry имеет max_elapsed_time, излишек дропается. Потери видны в # собственных метриках Collector (otelcol_*), которые тоже скрейпит Prometheus. receivers: otlp: protocols: http: endpoint: 0.0.0.0:4318 grpc: endpoint: 0.0.0.0:4317 processors: # memory_limiter ОБЯЗАТЕЛЬНО первый: отказывает в приёме до аллокации, # защищая контейнер от OOM при всплеске или залипшем exporter. memory_limiter: check_interval: 1s limit_mib: 128 spike_limit_mib: 32 resource: attributes: - key: deployment.environment.name value: lab action: upsert # SDK-атрибуты константны и не нужны в labels метрик — убираем, # чтобы не раздувать кардинальность Prometheus. - key: telemetry.sdk.language action: delete - key: telemetry.sdk.name action: delete - key: telemetry.sdk.version action: delete batch: timeout: 5s send_batch_size: 512 send_batch_max_size: 1024 exporters: # Метрики: pull-модель. Collector отдаёт /metrics, Prometheus скрейпит. # resource_to_telemetry_conversion превращает service.name и # service.instance.id в labels — это нужно для группировки по репликам. # Кардинальность ограничена: 2 API + 1 worker, конечный набор метрик. prometheus: endpoint: 0.0.0.0:8889 resource_to_telemetry_conversion: enabled: true add_metric_suffixes: true metric_expiration: 5m # Логи: Loki 3.x принимает OTLP нативно (/otlp/v1/logs). # Устаревший exporter "loki" удалён из Collector — не используем. otlphttp/loki: endpoint: http://loki:3100/otlp tls: insecure: true timeout: 10s sending_queue: enabled: true num_consumers: 2 queue_size: 100 # жёсткий потолок буфера: при переполнении дроп retry_on_failure: enabled: true initial_interval: 1s max_interval: 10s max_elapsed_time: 60s # не ретраим бесконечно # Трассы: Tempo, OTLP/gRPC. otlp/tempo: endpoint: tempo:4317 tls: insecure: true timeout: 10s sending_queue: enabled: true num_consumers: 2 queue_size: 100 retry_on_failure: enabled: true initial_interval: 1s max_interval: 10s max_elapsed_time: 60s extensions: health_check: endpoint: 0.0.0.0:13133 service: extensions: [health_check] pipelines: traces: receivers: [otlp] processors: [memory_limiter, resource, batch] exporters: [otlp/tempo] metrics: receivers: [otlp] processors: [memory_limiter, resource, batch] exporters: [prometheus] logs: receivers: [otlp] processors: [memory_limiter, resource, batch] exporters: [otlphttp/loki] telemetry: logs: level: info # Собственные метрики Collector: otelcol_exporter_send_failed_*, # otelcol_processor_dropped_*, otelcol_exporter_queue_size — # по ним считаем потери телеметрии в инциденте №3. metrics: readers: - pull: exporter: prometheus: host: 0.0.0.0 port: 8888