Files
mtusi2026lab7/infra/otel/collector.yaml
T

155 lines
6.8 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.
# OpenTelemetry Collector contrib 0.164.0 стенда vladimirceva-lab7.
#
# Collector — не хранилище: принимает OTLP от api, worker и relay, держит
# ограниченный буфер и раскладывает сигналы по трём backend:
# метрики → экспортёр prometheus :8889 → его забирает Prometheus;
# логи → OTLP/HTTP в Loki (родной приёмник /otlp);
# трассы → OTLP/HTTP в Tempo.
# Лаба 7, перенос telemetry-mtls: Collector работает в сетевом пространстве
# TLS-шлюза otel-gateway (infra/otel/gateway.cfg) и слушает только его loopback;
# :4318, :8888 и :8889 с mTLS и allowlist identity — порты шлюза. Перенос
# telemetry-backends-tls: экспорт в Loki и Tempo и scrape LB — https через их
# TLS-порты с leaf otel-collector-client (файлы — secrets Collector). Наружу ничего
# не опубликовано (compose.yaml).
receivers:
otlp:
protocols:
# SDK приложения шлёт только OTLP/HTTP protobuf; gRPC не включён. Только
# loopback: аутентификация — у шлюза, из сетей стенда приёмника нет
http:
endpoint: 127.0.0.1:14318
# метрики LB: встроенный экспортёр HAProxy на его TLS-порту (frontend monitor).
# Забирает Collector, а не Prometheus: у LB нет сети telemetry, у Prometheus —
# default. Только frontend и backend (без слотов и адресов реплик) и отобранные
# имена; job = haproxy. Сервер — по CA стенда и имени ingress (leaf LB), клиент —
# otel-collector-client; CRL клиент не умеет (матрица доверия)
prometheus/haproxy:
config:
scrape_configs:
- job_name: haproxy
scrape_interval: 15s
scrape_timeout: 10s
metrics_path: /metrics
params:
scope: [frontend, backend]
scheme: https
tls_config:
ca_file: /run/secrets/ca.crt
cert_file: /run/secrets/otel-collector-client.crt
key_file: /run/secrets/otel-collector-client.key
server_name: ingress
min_version: TLS13
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 отказывает приёмнику (SDK
# получит ошибку и отбросит пакет), а не растёт до OOM. Мягкий предел —
# 180 − 36 МиБ, жёсткий — 180 МиБ при лимите контейнера 256 МиБ
memory_limiter:
check_interval: 1s
limit_mib: 180
spike_limit_mib: 36
# пакеты к backend: по 512 элементов или раз в 2 с
batch:
send_batch_size: 512
send_batch_max_size: 1024
timeout: 2s
exporters:
# только loopback пространства шлюза: в сеть :8889 выводит otel-gateway
prometheus:
endpoint: 127.0.0.1:18889
# классические имена Prometheus: единица и _total суффиксами
# (http_server_request_duration_seconds_bucket, messenger_relay_jobs_total)
translation_strategy: UnderscoreEscapingWithSuffixes
# ряды остановленной реплики уходят из экспортёра через 3 мин
metric_expiration: 3m
# ресурс не размножает метки: service.name → job,
# service.instance.id → instance, остальное — в target_info
resource_to_telemetry_conversion:
enabled: false
# Очередь экспорта ограничена числом элементов и не блокирует приём:
# пока backend недоступен, Collector повторяет отправку до минуты, затем
# отбрасывает пакет; переполненная очередь отбрасывает новое. Потери видны
# в собственных метриках Collector (otelcol_exporter_send_failed_*,
# otelcol_exporter_enqueue_failed_*)
#
# Лаба 7: https через TLS-шлюзы хранилищ — leaf otel-collector-client, сервер по CA
# стенда и имени (системные корни не участвуют), TLS 1.3; CRL клиент не умеет
# (матрица доверия). Отказ TLS — недоступность backend: очередь и потери прежние
otlp_http/loki:
endpoint: https://loki:3100/otlp
timeout: 5s
tls:
ca_file: /run/secrets/ca.crt
cert_file: /run/secrets/otel-collector-client.crt
key_file: /run/secrets/otel-collector-client.key
min_version: "1.3"
sending_queue:
enabled: true
num_consumers: 2
sizer: items
queue_size: 20000
block_on_overflow: false
retry_on_failure:
enabled: true
initial_interval: 2s
max_interval: 10s
max_elapsed_time: 60s
otlp_http/tempo:
endpoint: https://tempo:4318
timeout: 5s
tls:
ca_file: /run/secrets/ca.crt
cert_file: /run/secrets/otel-collector-client.crt
key_file: /run/secrets/otel-collector-client.key
min_version: "1.3"
sending_queue:
enabled: true
num_consumers: 2
sizer: items
queue_size: 20000
block_on_overflow: false
retry_on_failure:
enabled: true
initial_interval: 2s
max_interval: 10s
max_elapsed_time: 60s
service:
telemetry:
logs:
level: info
# собственные метрики Collector (очереди, отказы, отброшенное) для
# Prometheus. Только loopback: в сеть :8888 выводит otel-gateway
metrics:
level: normal
readers:
- pull:
exporter:
prometheus:
host: 127.0.0.1
port: 18888
pipelines:
metrics:
receivers: [otlp, prometheus/haproxy]
processors: [memory_limiter, batch]
exporters: [prometheus]
logs:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [otlp_http/loki]
traces:
receivers: [otlp]
processors: [memory_limiter, batch]
exporters: [otlp_http/tempo]