forked from mtusi2026/mtusi2026lab6
ЛР6: OpenTelemetry, Collector, Prometheus/Loki/Tempo, Grafana, алерты, исследование цены наблюдаемости
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
# Профиль «tail sampling» (трек 1, lab6): SDK отправляет 100 % спанов, Collector оставляет
|
||||
# - все трассы с ошибками, - все медленные (> 500 мс), - 10 % остальных.
|
||||
# Метрики и логи без изменений. Подключается через COLLECTOR_CONFIG=/etc/otelcol/collector-tail.yaml.
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
grpc: {endpoint: 0.0.0.0:4317}
|
||||
http: {endpoint: 0.0.0.0:4318}
|
||||
|
||||
processors:
|
||||
memory_limiter: {check_interval: 1s, limit_mib: 280, spike_limit_mib: 60}
|
||||
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.statement, action: delete}
|
||||
- {key: url.query, action: delete}
|
||||
tail_sampling:
|
||||
decision_wait: 5s
|
||||
num_traces: 20000
|
||||
expected_new_traces_per_sec: 500
|
||||
policies:
|
||||
- {name: errors, type: status_code, status_code: {status_codes: [ERROR]}}
|
||||
- {name: slow, type: latency, latency: {threshold_ms: 500}}
|
||||
- {name: baseline, type: probabilistic, probabilistic: {sampling_percentage: 10}}
|
||||
|
||||
exporters:
|
||||
otlp_grpc/tempo:
|
||||
endpoint: tempo:4317
|
||||
tls: {insecure: true}
|
||||
sending_queue: {enabled: true, num_consumers: 2, queue_size: 500}
|
||||
retry_on_failure: {enabled: true, initial_interval: 1s, max_interval: 10s, max_elapsed_time: 30s}
|
||||
otlp_http/loki:
|
||||
endpoint: http://loki:3100/otlp
|
||||
sending_queue: {enabled: true, num_consumers: 2, queue_size: 500}
|
||||
retry_on_failure: {enabled: true, initial_interval: 1s, max_interval: 10s, max_elapsed_time: 30s}
|
||||
prometheus:
|
||||
endpoint: 0.0.0.0:8889
|
||||
resource_to_telemetry_conversion: {enabled: true}
|
||||
metric_expiration: 20s
|
||||
|
||||
service:
|
||||
telemetry:
|
||||
metrics:
|
||||
level: normal
|
||||
readers:
|
||||
- pull:
|
||||
exporter:
|
||||
prometheus: {host: 0.0.0.0, port: 8888}
|
||||
logs: {level: warn}
|
||||
pipelines:
|
||||
traces:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, attributes/scrub, tail_sampling, batch]
|
||||
exporters: [otlp_grpc/tempo]
|
||||
metrics:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [prometheus]
|
||||
logs:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, attributes/scrub, batch]
|
||||
exporters: [otlp_http/loki]
|
||||
@@ -0,0 +1,75 @@
|
||||
# OpenTelemetry Collector (contrib). Один пайплайн на сигнал, у каждого — реальный backend:
|
||||
# traces -> Tempo (OTLP/gRPC)
|
||||
# metrics -> Prometheus (Prometheus-экспортёр: Prometheus сам забирает /metrics у Collector)
|
||||
# logs -> Loki (OTLP/HTTP, нативный приём Loki)
|
||||
# Collector — маршрутизатор/обработчик, не долговременное хранилище. Порты 4317/4318 доступны ТОЛЬКО во внутренней сети backend.
|
||||
receivers:
|
||||
otlp:
|
||||
protocols:
|
||||
grpc:
|
||||
endpoint: 0.0.0.0:4317
|
||||
http:
|
||||
endpoint: 0.0.0.0:4318
|
||||
|
||||
processors:
|
||||
# Защита RAM Collector: при приближении к лимиту новые данные отклоняются (клиент SDK получает ошибку и отбрасывает
|
||||
# пакет, приложение продолжает работать). limit_mib согласован с mem_limit контейнера.
|
||||
memory_limiter:
|
||||
check_interval: 1s
|
||||
limit_mib: 280
|
||||
spike_limit_mib: 60
|
||||
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: http.request.body, action: delete}
|
||||
- {key: db.statement, action: delete}
|
||||
- {key: url.query, action: delete}
|
||||
- {key: http.target, action: delete}
|
||||
# Tail-sampling (профиль «tail», см. collector-tail.yaml): здесь не используется.
|
||||
|
||||
exporters:
|
||||
otlp_grpc/tempo:
|
||||
endpoint: tempo:4317
|
||||
tls: {insecure: true}
|
||||
# Ограниченная буферизация при недоступном backend: очередь фиксированного размера, повторы до 30 с, затем отбрасывание
|
||||
# (потери считаются метрикой otelcol_exporter_send_failed_spans / otelcol_exporter_queue_size).
|
||||
sending_queue: {enabled: true, num_consumers: 2, queue_size: 500}
|
||||
retry_on_failure: {enabled: true, initial_interval: 1s, max_interval: 10s, max_elapsed_time: 30s}
|
||||
otlp_http/loki:
|
||||
endpoint: http://loki:3100/otlp
|
||||
sending_queue: {enabled: true, num_consumers: 2, queue_size: 500}
|
||||
retry_on_failure: {enabled: true, initial_interval: 1s, max_interval: 10s, max_elapsed_time: 30s}
|
||||
prometheus:
|
||||
endpoint: 0.0.0.0:8889
|
||||
resource_to_telemetry_conversion: {enabled: true}
|
||||
metric_expiration: 20s
|
||||
|
||||
service:
|
||||
telemetry:
|
||||
metrics:
|
||||
level: normal
|
||||
readers:
|
||||
- pull:
|
||||
exporter:
|
||||
prometheus: {host: 0.0.0.0, port: 8888}
|
||||
logs:
|
||||
level: warn
|
||||
pipelines:
|
||||
traces:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, attributes/scrub, batch]
|
||||
exporters: [otlp_grpc/tempo]
|
||||
metrics:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, batch]
|
||||
exporters: [prometheus]
|
||||
logs:
|
||||
receivers: [otlp]
|
||||
processors: [memory_limiter, attributes/scrub, batch]
|
||||
exporters: [otlp_http/loki]
|
||||
Reference in New Issue
Block a user