forked from mtusi2026/mtusi2026lab6
Перенесён минимум lab5 без изменения API и добавлена наблюдаемость: - OTel SDK в API и worker: traces, metrics, logs по OTLP; W3C trace context API -> outbox -> RabbitMQ -> worker (producer/consumer spans, retry в той же трассе); - OTel Collector (memory_limiter, scrub, batch, ограниченные очереди, профиль tail sampling), Prometheus, Loki, Tempo, Grafana с provisioning, dashboard и 6 alert rules с runbooks; - проверки: наблюдаемость и приватность, инциденты A/B/C, насыщение worker, переполнение очереди exporter, эксперимент трека 1 (4 конфигурации x 3 прогона); - CI job со сборкой и запуском стенда; REPORT.md с доказательствами в evidence/.
89 lines
3.1 KiB
YAML
89 lines
3.1 KiB
YAML
# OpenTelemetry Collector (contrib 0.120.0): receiver/processor/exporter only, it stores nothing long-term.
|
|
# API, worker --OTLP/HTTP:4318--> collector --> Prometheus (metrics, OTLP), Loki (logs, OTLP), Tempo (traces, OTLP/gRPC)
|
|
# Ports are reachable only inside the compose network; nothing here is published to the host.
|
|
extensions:
|
|
health_check:
|
|
endpoint: 0.0.0.0:13133
|
|
|
|
receivers:
|
|
otlp:
|
|
protocols:
|
|
grpc:
|
|
endpoint: 0.0.0.0:4317
|
|
http:
|
|
endpoint: 0.0.0.0:4318
|
|
max_request_body_size: 4194304 # 4 MiB per OTLP request
|
|
|
|
processors:
|
|
# First in every pipeline: refuse new data (receivers answer 503 -> SDK retries/drops) before the container OOMs.
|
|
# Container limit is 256 MiB; soft limit = limit_mib - spike_limit_mib = 140 MiB.
|
|
memory_limiter:
|
|
check_interval: 1s
|
|
limit_mib: 180
|
|
spike_limit_mib: 40
|
|
batch:
|
|
send_batch_size: 1024
|
|
send_batch_max_size: 2048
|
|
timeout: 2s
|
|
# Defense in depth: even if an instrumentation adds them, these attributes never leave the collector.
|
|
# url.query would contain ?filename=...; headers could contain Authorization.
|
|
attributes/scrub:
|
|
actions:
|
|
- {key: url.query, action: delete}
|
|
- {key: url.full, action: delete}
|
|
- {key: http.target, action: delete}
|
|
- {key: http.url, action: delete}
|
|
- {key: http.request.header.authorization, action: delete}
|
|
- {key: http.request.header.cookie, action: delete}
|
|
- {key: db.query.parameters, action: delete}
|
|
|
|
exporters:
|
|
# Every exporter: bounded in-memory queue (batches) + bounded retry. Backend down => queue fills, then new
|
|
# batches are dropped and counted (otelcol_exporter_enqueue_failed_*); RAM stays bounded, apps are unaffected.
|
|
otlphttp/prometheus:
|
|
endpoint: http://prometheus:9090/api/v1/otlp
|
|
compression: gzip
|
|
timeout: 5s
|
|
sending_queue: {enabled: true, num_consumers: 2, queue_size: 100}
|
|
retry_on_failure: {enabled: true, initial_interval: 1s, max_interval: 10s, max_elapsed_time: 120s}
|
|
otlphttp/loki:
|
|
endpoint: http://loki:3100/otlp
|
|
compression: gzip
|
|
timeout: 5s
|
|
sending_queue: {enabled: true, num_consumers: 2, queue_size: 100}
|
|
retry_on_failure: {enabled: true, initial_interval: 1s, max_interval: 10s, max_elapsed_time: 120s}
|
|
otlp/tempo:
|
|
endpoint: tempo:4317
|
|
tls: {insecure: true}
|
|
compression: gzip
|
|
timeout: 5s
|
|
sending_queue: {enabled: true, num_consumers: 2, queue_size: 100}
|
|
retry_on_failure: {enabled: true, initial_interval: 1s, max_interval: 10s, max_elapsed_time: 120s}
|
|
|
|
service:
|
|
extensions: [health_check]
|
|
telemetry:
|
|
logs:
|
|
level: info
|
|
metrics:
|
|
level: detailed
|
|
readers:
|
|
- pull:
|
|
exporter:
|
|
prometheus:
|
|
host: 0.0.0.0
|
|
port: 8888
|
|
pipelines:
|
|
traces:
|
|
receivers: [otlp]
|
|
processors: [memory_limiter, attributes/scrub, batch]
|
|
exporters: [otlp/tempo]
|
|
metrics:
|
|
receivers: [otlp]
|
|
processors: [memory_limiter, batch]
|
|
exporters: [otlphttp/prometheus]
|
|
logs:
|
|
receivers: [otlp]
|
|
processors: [memory_limiter, attributes/scrub, batch]
|
|
exporters: [otlphttp/loki]
|