본문 바로가기
Q&A해결2026년 4월 27일1분 읽기

OpenTelemetry Collector 0.110에서 메모리가 점진적으로 증가합니다

관
관측성담당
조회 725댓글 1

OpenTelemetry Collector contrib 이미지 0.110으로 업그레이드했더니 메모리 사용량이 시간이 지날수록 계속 증가합니다.

0.105 시점에는 안정적으로 1~1.5GB에 머물렀는데 0.110은 24시간 후 4GB까지 늘어납니다. 누수 의심인데 어떻게 진단하나요?

댓글 1

김김영삼7개월 전

OpenTelemetry Collector 0.110의 알려진 이슈입니다. 0.108~0.110 사이에 도입된 batch processor 변경과 일부 receiver의 cardinality 처리 차이가 합쳐진 결과입니다.

1) 즉시 진단 — pprof 활성화

extensions:
pprof:
endpoint: 0.0.0.0:1777

service:
extensions: [pprof]
pipelines:
...
# heap profile 다운로드
go tool pprof http://collector:1777/debug/pprof/heap
# (pprof) top 20
# 가장 메모리 점유 큰 함수 보기

대부분 케이스에서 metrics receiver 또는 batch processor에 큰 점유가 보입니다.

2) 흔한 원인 #1 — high cardinality metric

특정 라벨 조합이 폭발적으로 증가하면 prometheusremotewrite·prometheus exporter가 누적합니다.

# 라벨 카디널리티 점검
curl http://collector:8888/metrics | \
awk -F'{' '{print $1}' | sort | uniq -c | sort -rn | head

# 한 메트릭 이름 안에서 라벨 조합 수 확인
curl 'http://prometheus:9090/api/v1/label/instance/values' | jq '.data | length'

흔한 가해자:

  • HTTP path를 라벨로 그대로 사용 (path /api/users/12345 → 사용자마다 새 series)
  • request_id, trace_id를 metric 라벨로 사용 (절대 금지)
  • error message를 라벨로 사용 (메시지 변형이 모두 새 series)

해결 — transform processor로 cardinality 줄이기

processors:
transform:
metric_statements:
- context: datapoint
statements:
- replace_pattern(attributes["http.target"], "/api/users/\\d+", "/api/users/:id")
- replace_pattern(attributes["http.target"], "/api/orders/[a-f0-9-]+", "/api/orders/:id")
- delete_key(attributes, "request_id")

3) 흔한 원인 #2 — batch processor 동작 변경

0.108부터 batch processor가 per-resource batching으로 바뀌면서 일부 워크로드에서 batch가 작게 형성되고 메모리에 오래 남는 현상이 있습니다.

# 영향 줄이기 — batch 강제 주기 짧게
processors:
batch:
send_batch_size: 8192
timeout: 1s # 5s → 1s
send_batch_max_size: 10000

4) 흔한 원인 #3 — memory_limiter 부재

processors:
memory_limiter:
check_interval: 1s
limit_mib: 1500
spike_limit_mib: 300

service:
pipelines:
metrics:
processors: [memory_limiter, batch, transform]

memory_limiter는 항상 첫 번째 processor여야 합니다. 한도 도달 시 들어오는 데이터를 거부해 OOM·OOMKill을 방지.

5) 0.110 특화 — receiver별 issue 점검

Receiver0.110 이슈otlpHTTP 모드 keep-alive connection이 누수되는 케이스 (#37412)prometheusscrape target dynamic discovery 시 mem leak (#37456)fileloglarge log file 회전 시 file handle 누수 (#37398)

해당 receiver를 사용한다면 0.111 또는 0.105로 다운그레이드 검토.

6) 단기 처방 — 주기적 재시작

# Kubernetes
spec:
template:
spec:
containers:
- name: otel-collector
...
livenessProbe:
httpGet:
path: /
port: 13133
initialDelaySeconds: 0
periodSeconds: 30
extensions:
health_check:
endpoint: 0.0.0.0:13133

processors:
memory_limiter:
limit_mib: 2000
# 한도 도달 시 health_check가 unhealthy로 응답 → k8s가 재시작

"메모리 누수가 있는 동안만이라도 자동 재시작으로 견디기" 패턴.

7) 장기 처방

  1. 0.105 LTS로 다운그레이드 (이슈 안정화될 때까지)
  2. 또는 0.111+ 까지 기다리기 (5월 중순 예상)
  3. cardinality 감사 — 매주 top 20 metric series 수 추적
  4. memory_limiter 필수 + alarm
  5. multi-collector — 하나는 receiver, 다른 하나는 processor·exporter 분리

아키텍처 권장 — Agent + Gateway 분리

App Pod
↓ otlp grpc
[Agent Collector] (per node, daemonset)
↓ otlp grpc batched
[Gateway Collector] (deployment, replicas: 3)
↓
Prometheus / Tempo / Loki

Agent는 가벼운 receiver+resource detector만, Gateway는 무거운 transform·batch+exporter. 메모리 부담 분산 효과 큼.

실무 체크리스트

  1. pprof로 메모리 점유 함수 확인
  2. cardinality 감사 (매주)
  3. memory_limiter 첫 processor로
  4. batch timeout 짧게 (1초)
  5. transform으로 라벨 normalize
  6. 0.111 LTS 패치 대기 또는 0.105 다운그레이드
  7. Agent + Gateway 분리

OTel Collector 메모리 이슈의 90%는 cardinality 폭발 + memory_limiter 부재입니다. 위 두 가지부터 점검하세요.

Ctrl+Enter로 등록