DOCS/troubleshooting/250929_51123_fluent_bit_container_metadata_missing.md

2.3 KiB

date, author, tags
date author tags
2025-09-29 admin
fluent-bit
opensearch
logging
docker

Fluent Bit 컨테이너 메타데이터 수집 실패 문제

문제 상황

  • 발생일: 2025-09-27 12:22 재시작 이후
  • 환경: 51123 서버 Fluent Bit → Data Prepper → OpenSearch
  • 증상: 컨테이너 로그는 수집되나 container_name 필드 누락 (모두 "unknown")
  • 영향: 9/27 19:16 이후 대부분 컨테이너 로그 식별 불가

원인 분석

타임라인

  • 9/27 12:22: Fluent Bit 컨테이너 재시작 (hostexecutor-fluent-bit 이미지)
  • 9/27 19:16: 마지막 정상 rb8001 로그 수집
  • 9/28: 전체 컨테이너 로그 수집 실패 (fluent-bit 자체 로그만)
  • 9/29: 일부 복구되었으나 메타데이터 여전히 누락

근본 원인

# 현재 설정
[INPUT]
    Name              tail
    Path              /var/lib/docker/containers/*/*-json.log
    Parser            docker
    Docker_Mode       On  # 로그 본문 병합용, 메타데이터 추출과 무관
  1. 메타데이터 추출 방법 부재: tail 입력은 파일만 읽고 컨테이너 정보 추출 못함
  2. /var/run/docker.sock 미마운트: Docker API 접근 불가
  3. Fluent Bit 4.0.9에 docker 필터 없음: 'docker'라는 이름의 필터 플러그인 미존재

해결 방안

1. fluent-bit.conf 수정 - INPUT docker 사용

  • 현재 tail 입력 제거
  • docker 입력 플러그인으로 교체 (container_name 자동 추출)
  • /var/run/docker.sock 마운트 필수

2. docker-compose.yaml 수정

  • 위치: /home/happybell80/ivada_project/fluent-bit/docker-compose.yaml
  • 추가 필요: /var/run/docker.sock:/var/run/docker.sock:ro 마운트

3. Dockerfile 오류

  • 13번 라인: COPY certs/root.pem /fluent-bit/certs/root.pem
  • 문제: certs 디렉토리 없음
  • 조치: 해당 라인 제거 또는 주석 처리 필요

검증 명령

# 컨테이너별 로그 확인
curl -s "http://localhost:9200/dataprepper-*/_search" | \
  python3 -c "import sys,json; [print(h['_source'].get('container_name','unknown')) for h in json.load(sys.stdin)['hits']['hits']]"

교훈

  • Docker 이미지 내장 설정은 변경 추적 어려움
  • 중요 설정은 외부 파일로 관리 필수
  • Fluent Bit Docker_Mode는 FILTER와 함께 사용해야 함