forked from mtusi2026/mtusi2026lab7
ЛР 7 — БВТ2301 — Курлова — на 4
Перенесён минимум lab6 (API без изменений), добавлена защита на границах доверия: - внешний HTTPS; обязательный mTLS LB -> API с allowlist identity и отзывом по serial; - TLS на всех связях: PostgreSQL verify-full, MinIO HTTPS, RabbitMQ AMQPS mTLS (EXTERNAL), Valkey TLS + ACL, Collector и хранилища телеметрии через mTLS с отдельными CA; - OpenBao в server mode: cert auth, токены 15 мин, политики только на свой путь; - роли БД, S3-политики и права брокера по принципу минимальных прав; - Argon2id с замером, rehash, общий лимит входа, бюджет защиты от login DoS; - hardening всех контейнеров, scan образов с разбором, модель угроз, матрица доверия; - отрицательные тесты: TLS-аудит (135 проверок), ACL, ротации, sealed OpenBao.
This commit is contained in:
@@ -0,0 +1,111 @@
|
||||
# OpenTelemetry Collector (contrib 0.120.0): receiver/processor/exporter only, it stores nothing long-term.
|
||||
# API, worker --OTLP/HTTPS:4318 (mTLS)--> collector --mTLS--> Prometheus (OTLP), Loki (OTLP), Tempo (OTLP/gRPC)
|
||||
# lab7: the receiver trusts ONLY the "Telemetry Ingest CA" (client_ca_file): api-otel / worker-otel certificates.
|
||||
# A certificate from the root CA (LB, api, worker identities) or no certificate cannot push telemetry.
|
||||
# Outbound: the collector presents collector-out (Telemetry Clients CA) and verifies each backend's server cert.
|
||||
extensions:
|
||||
health_check:
|
||||
endpoint: 127.0.0.1:13133 # loopback only (no Docker healthcheck: distroless image)
|
||||
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
http:
|
||||
endpoint: 0.0.0.0:4318
|
||||
max_request_body_size: 4194304 # 4 MiB per OTLP request
|
||||
tls:
|
||||
cert_file: /run/secrets/server.crt
|
||||
key_file: /run/secrets/server.key
|
||||
client_ca_file: /run/secrets/ingest-ca.crt
|
||||
min_version: "1.2"
|
||||
|
||||
prometheus/self:
|
||||
config:
|
||||
scrape_configs:
|
||||
- job_name: otel-collector
|
||||
scrape_interval: 15s
|
||||
static_configs: [{targets: ["127.0.0.1:8888"]}]
|
||||
|
||||
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 verifies the backend against the lab root CA and authenticates as collector-out (mTLS).
|
||||
otlphttp/prometheus:
|
||||
endpoint: https://prometheus:9090/api/v1/otlp
|
||||
tls: &client_tls
|
||||
ca_file: /run/secrets/ca.crt
|
||||
cert_file: /run/secrets/client.crt
|
||||
key_file: /run/secrets/client.key
|
||||
min_version: "1.2"
|
||||
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: https://loki:3100/otlp
|
||||
tls: *client_tls
|
||||
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: *client_tls
|
||||
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:
|
||||
# Stable identity of the collector's own metrics (default is a random UUID per restart -> label churn).
|
||||
resource:
|
||||
service.instance.id: otel-collector
|
||||
logs:
|
||||
level: info
|
||||
metrics:
|
||||
level: detailed
|
||||
# lab7: self-metrics are served on LOOPBACK only and scraped by the collector itself (receiver
|
||||
# prometheus/self), then exported through the normal metrics pipeline over mTLS. Nothing is reachable from the
|
||||
# network in plaintext. (Direct OTLP push of internal telemetry ignored client certificates in 0.120.0.)
|
||||
readers:
|
||||
- pull:
|
||||
exporter:
|
||||
prometheus:
|
||||
host: 127.0.0.1
|
||||
port: 8888
|
||||
pipelines:
|
||||
traces:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, attributes/scrub, batch]
|
||||
exporters: [otlp/tempo]
|
||||
metrics:
|
||||
receivers: [otlp, prometheus/self]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [otlphttp/prometheus]
|
||||
logs:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, attributes/scrub, batch]
|
||||
exporters: [otlphttp/loki]
|
||||
@@ -0,0 +1,5 @@
|
||||
# Default profile: no extra processing. All spans that the SDK head-sampled are exported.
|
||||
# Selected with COLLECTOR_PROFILE=default (see compose.yaml); merged over collector.yaml.
|
||||
processors:
|
||||
batch:
|
||||
timeout: 2s
|
||||
@@ -0,0 +1,31 @@
|
||||
# Track 1 "balanced" profile (COLLECTOR_PROFILE=tail): SDK keeps 100% head sampling, the collector decides per
|
||||
# whole trace after decision_wait. Keeps: every trace with an error, every trace slower than 500 ms, every trace of
|
||||
# the attachment pipeline (rare, async, valuable), and 10% of the remaining ordinary traffic.
|
||||
# Metrics are computed in the SDK BEFORE any sampling, so RPS/error rate/percentiles are unaffected.
|
||||
processors:
|
||||
tail_sampling:
|
||||
decision_wait: 10s
|
||||
num_traces: 20000
|
||||
expected_new_traces_per_sec: 200
|
||||
decision_cache:
|
||||
sampled_cache_size: 50000
|
||||
policies:
|
||||
- name: keep-errors
|
||||
type: status_code
|
||||
status_code: {status_codes: [ERROR]}
|
||||
- name: keep-slow
|
||||
type: latency
|
||||
latency: {threshold_ms: 500}
|
||||
- name: keep-async-pipeline
|
||||
type: string_attribute
|
||||
string_attribute: {key: messaging.system, values: [rabbitmq]}
|
||||
- name: baseline-10pct
|
||||
type: probabilistic
|
||||
probabilistic: {sampling_percentage: 10}
|
||||
|
||||
service:
|
||||
pipelines:
|
||||
traces:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, attributes/scrub, tail_sampling, batch]
|
||||
exporters: [otlp/tempo]
|
||||
Reference in New Issue
Block a user