# OpenTelemetry Collector (contrib 0.111.0): приём OTLP от API и worker → три хранилища. # lab7: Collector делит сетевое пространство с sidecar otel-gw (HAProxy). Снаружи OTLP # принимает ТОЛЬКО otel-gw: TLS + обязательный клиентский сертификат + allowlist CN {api, worker} # + CRL. Сам Collector слушает 127.0.0.1:14318 — loopback общего netns, из сети недоступен. # К хранилищам Collector ходит по mTLS сертификатом identity otel-collector. # traces → Tempo (OTLP gRPC) # logs → Loki (нативный OTLP-приём Loki 3.x, /otlp) # metrics → Prometheus (remote write) # Collector — не хранилище: очереди экспортёров ограничены, при долгой недоступности # backend данные отбрасываются (и считаются в otelcol_exporter_send_failed_*). receivers: otlp: protocols: http: endpoint: 127.0.0.1:14318 # только loopback: снаружи — через otel-gw (mTLS + allowlist) # Собственные метрики Collector: он сам читает их с 127.0.0.1:8888 и отправляет в Prometheus # по mTLS вместе с остальными (Prometheus не скрейпит Collector по открытому HTTP). prometheus/self: config: scrape_configs: - job_name: otel-collector scrape_interval: 10s static_configs: - targets: ["127.0.0.1:8888"] processors: # Первым в каждом pipeline: при приближении к лимиту Collector отказывает в приёме # (SDK получает ошибку и отбрасывает данные у себя), а не растёт по памяти до OOM. memory_limiter: check_interval: 1s limit_mib: 160 # контейнер ограничен 256 МиБ spike_limit_mib: 40 batch: send_batch_size: 1024 send_batch_max_size: 2048 timeout: 2s # Защита от утечек: даже если какой-то атрибут с секретом появится, он будет удалён. attributes/scrub: actions: - {key: http.request.header.authorization, action: delete} - {key: http.request.header.cookie, action: delete} - {key: db.query.parameter, action: delete} - {key: url.query, action: delete} exporters: otlp/tempo: endpoint: tempo:4317 # mTLS: сервер — по CA и SAN «tempo», клиент — otel-collector tls: ca_file: /tls/ca.crt cert_file: /tls/tls.crt key_file: /tls/tls.key min_version: "1.2" timeout: 5s sending_queue: {enabled: true, num_consumers: 2, queue_size: 200} # ≤ 200 батчей в памяти retry_on_failure: {enabled: true, initial_interval: 1s, max_interval: 10s, max_elapsed_time: 60s} otlphttp/loki: endpoint: https://loki:3100/otlp tls: ca_file: /tls/ca.crt cert_file: /tls/tls.crt key_file: /tls/tls.key min_version: "1.2" timeout: 5s sending_queue: {enabled: true, num_consumers: 2, queue_size: 200} retry_on_failure: {enabled: true, initial_interval: 1s, max_interval: 10s, max_elapsed_time: 60s} prometheusremotewrite: endpoint: https://prometheus:9090/api/v1/write # Prometheus пускает только SAN otel-collector/grafana tls: ca_file: /tls/ca.crt cert_file: /tls/tls.crt key_file: /tls/tls.key min_version: "1.2" timeout: 5s remote_write_queue: {enabled: true, queue_size: 2000, num_consumers: 2} retry_on_failure: {enabled: true, initial_interval: 1s, max_interval: 10s, max_elapsed_time: 60s} resource_to_telemetry_conversion: {enabled: false} # job=service.name, instance=service.instance.id target_info: {enabled: true} extensions: health_check: endpoint: 127.0.0.1:13133 service: extensions: [health_check] pipelines: traces: receivers: [otlp] processors: [memory_limiter, attributes/scrub, batch] exporters: [otlp/tempo] logs: receivers: [otlp] processors: [memory_limiter, batch] exporters: [otlphttp/loki] metrics: receivers: [otlp, prometheus/self] processors: [memory_limiter, batch] exporters: [prometheusremotewrite] telemetry: logs: level: info metrics: level: detailed address: 127.0.0.1:8888 # собственные метрики Collector (читает receiver prometheus/self)