Kubernetes의 컨테이너 로그를 Fluent Bit로 읽어 Elasticsearch에 보내고 Kibana에서 검색하는 환경을 구성했다. 설치 뒤 일부 인덱스에 문서가 생긴 것은 확인했지만, 전송 재시도와 매핑 오류가 이어졌다. 설치 과정에서 마주친 응답 버퍼 부족과 색인 매핑 충돌을 구분하고, 각 오류가 수집 경로의 어느 단계에서 발생했는지 살펴본다.

1. 수집·저장·조회 경로와 사용 버전

plain text
컨테이너·노드 로그
  → Fluent Bit: 입력, 파싱·필터, 버퍼, Elasticsearch 출력
  → Elasticsearch: 문서 색인과 검색
  → Kibana: 데이터 뷰, 검색, 대시보드

EFK의 F는 보통 Fluentd를 가리키지만 이 구성에서는 Fluent Bit를 사용했다. 가용 자원이 적고 로그 가공 요구가 복잡하지 않았던 환경에 맞춘 선택이었다. Fluent Bit와 Fluentd는 플러그인과 설정 문법이 다르다.

항목기록에 남은 값해석
Helm4.1.4설치·버전 출력이 남아 있다.
Elasticsearch chart / app8.5.1 / 8.5.1당시 저장소 검색 결과다.
Kibana chart / app8.5.1 / 8.5.1Elasticsearch와 연결할 버전을 맞춘다.
Fluent Bit chart / app0.57.3 / 5.0.3chart 버전과 프로그램 버전은 별개다.
네임스페이스logging아래 리소스와 Secret 참조의 기준이다.

기록의 Elastic Helm 저장소는 2023년에 보관 처리된 저장소다. 저장소 검색에서 8.5.1이 보인다는 사실을 현재 지원되는 최신 Elastic Stack이라는 뜻으로 사용하지 않는다. 이 문서는 당시 설치·장애 기록이며 신규 운영 배포 방식은 지원 버전과 ECK 등을 별도로 검토한다. Elastic Helm chart 저장소의 유지관리 안내

당시 Helm 설치·체크섬과 버전 출력
plain text
curl -LO https://get.helm.sh/helm-v4.1.4-linux-amd64.tar.gz.sha256sum
curl -LO https://get.helm.sh/helm-v4.1.4-linux-amd64.tar.gz

sha256sum -c helm-v4.1.4-linux-amd64.tar.gz.sha256sum
helm-v4.1.4-linux-amd64.tar.gz: OK

tar xvf helm-v4.1.4-linux-amd64.tar.gz 
mv linux-amd64/helm /usr/local/bin/

which helm
/usr/local/bin/helm

helm version
version.BuildInfo{Version:"v4.1.4", GitCommit:"05fa37973dc9e42b76e1d2883494c87174b6074f", GitTreeState:"clean", GoVersion:"go1.25.9", KubeClientVersion:"v1.35"}

2. 차트를 준비하고 배포할 때 확인한 조건

저장소를 등록하고 차트를 검색했다. 같은 환경을 재현하려면 차트 버전을 명시하고 values와 차트 파일을 함께 보관한다.

bash
helm repo add elastic https://helm.elastic.co
helm repo add fluent https://fluent.github.io/helm-charts
helm repo update
helm search repo elastic
helm search repo fluent

# 당시 사용 버전을 재현하는 예
helm pull elastic/elasticsearch --version 8.5.1 --untar
helm pull elastic/kibana --version 8.5.1 --untar
helm pull fluent/fluent-bit --version 0.57.3 --untar
kubectl create namespace logging

스토리지 클래스·PVC, Elasticsearch 노드 수와 JVM heap, Kibana 연결 주소, Fluent Bit 입력·필터·출력을 먼저 맞춘다. CPU 500m·메모리 1Gi는 실습에서 검토한 자원 예시다. Elasticsearch·Kibana·Fluent Bit의 역할과 부하가 다르므로 각 컴포넌트별로 requests·limits를 산정한다.

bash
# 각 차트의 values를 준비하고 렌더링 결과를 확인한 뒤 배포한다.
helm template elasticsearch ./elasticsearch -n logging -f elasticsearch-values.yaml
helm template fluent-bit ./fluent-bit -n logging -f fluent-bit-values.yaml
helm template kibana ./kibana -n logging -f kibana-values.yaml

helm install elasticsearch ./elasticsearch -n logging -f elasticsearch-values.yaml
helm install fluent-bit ./fluent-bit -n logging -f fluent-bit-values.yaml
helm install kibana ./kibana -n logging -f kibana-values.yaml

예제의 values 파일명은 설명용이다. Helm 배포 시 사용할 values를 명시하고, Kibana와 Fluent Bit의 Elasticsearch 접속 주소·포트·프로토콜을 실제 서비스 설정과 맞춘다.

3. Fluent Bit 출력의 인증과 TLS를 맞추기

초기 메모는 TLS를 켜고 인증서 검증은 끈 상태였다. 뒤의 설정에는 CA Secret 마운트가 추가됐지만 kube. 출력은 검증을 켜고 host. 출력은 끈 값이 섞여 있었다. 같은 Elasticsearch를 대상으로 한다면 두 출력의 신뢰 설정을 의도적으로 맞춰야 한다.

아래는 당시 구성을 정돈한 values 부분 예제다. CA와 자격증명 Secret이 logging에 존재하고 해당 CA가 서비스 이름으로 제시되는 인증서를 검증할 수 있다는 전제다. 실제 입력 태그가 kube.·host.인지도 확인한다.

yaml
extraVolumes:
  - name: es-ca
    secret:
      secretName: elasticsearch-master-certs
extraVolumeMounts:
  - name: es-ca
    mountPath: /tls
    readOnly: true

env:
  - name: ELASTIC_ID
    valueFrom:
      secretKeyRef:
        name: elasticsearch-master-credentials
        key: username
  - name: ELASTIC_PASSWORD
    valueFrom:
      secretKeyRef:
        name: elasticsearch-master-credentials
        key: password

config:
  outputs: |
    [OUTPUT]
        Name es
        Match kube.*
        Host elasticsearch-master
        Port 9200
        HTTP_User ${ELASTIC_ID}
        HTTP_Passwd ${ELASTIC_PASSWORD}
        tls On
        tls.verify On
        tls.ca_file /tls/ca.crt
        Suppress_Type_Name On
        Logstash_Format On
        Logstash_Prefix kube

    [OUTPUT]
        Name es
        Match host.*
        Host elasticsearch-master
        Port 9200
        HTTP_User ${ELASTIC_ID}
        HTTP_Passwd ${ELASTIC_PASSWORD}
        tls On
        tls.verify On
        tls.ca_file /tls/ca.crt
        Suppress_Type_Name On
        Logstash_Format On
        Logstash_Prefix node

config.outputs에 classic Fluent Bit 설정 문자열을 넣는 구조와 Kubernetes env 목록을 구분했다. 이는 전체 수집기 설정이 아니므로 inputs·filters가 만드는 태그와 필드 구조를 함께 병합한다. Fluent Bit Helm values

Logstash_Format On은 날짜별 인덱스 이름을 쓰는 옵션이지 Logstash 프로세스를 설치했다는 의미가 아니다. 실습의 logstash-2026.04.18도 이 이름 규칙에 따른 것이며, host. 출력에 Logstash_Prefix node를 주면 node- 계열로 간다.

Suppress_Type_Name On은 Elasticsearch 8 계열과 연결할 때 mapping type 관련 요청 형식을 맞추는 옵션이다. 인증 실패, CA 신뢰 실패, 태그 미일치, 색인 거부는 서로 다른 단계의 문제이므로 하나의 옵션으로 모두 해결됐다고 보지 않는다. Elasticsearch 출력 옵션

Secret에 저장한 값을 확인하는 명령은 다음과 같다. base64 디코딩 결과에는 실제 자격증명이 노출되므로 출력의 보관·공유 범위를 제한한다.

bash
kubectl get secrets -n logging elasticsearch-master-credentials  -o jsonpath={.data.username} | base64 -d
kubectl get secrets -n logging elasticsearch-master-credentials  -o jsonpath={.data.password} | base64 -d

4. 처음 확인한 수집 결과와 그 한계

작성자는 Secret의 계정으로 Kibana에 접속했고, 인덱스 조회에서 아래 문서 수를 기록했다.

plain text
index                 docs.count  store.size
logstash-2026.04.18    232         539.9kb
node-2026.04.18        19          202.7kb

이 결과는 일부 문서가 저장됐다는 증거다. 모든 로그의 수집 성공, 장기간 누락 없음, 필드별 집계와 대시보드의 완성을 의미하지 않는다. Kibana는 Elasticsearch 데이터를 조회하면서 데이터 뷰·대시보드 같은 저장 객체도 사용하므로 “자체 설정 데이터가 전혀 없다”고 설명하지 않는다.

그다음 Fluent Bit의 debug 로그와 Trace_Error On으로 전송 실패를 조사했다. 상세 출력에는 실제 로그 본문이 들어갈 수 있어 조사 뒤에는 운영 로그 수준과 공개 범위를 다시 조정한다.

5. 응답 버퍼 부족·429·매핑 오류를 구분한 조사

5.1 512000바이트 응답 버퍼에 544768바이트가 필요했던 경우

당시 출력은 다음과 같다.

plain text
cannot increase buffer: current=512000 requested=544768 max=512000
http_do=-1 URI=/_bulk
failed to flush chunk ... retry ...

Elasticsearch 출력의 Buffer_Size는 Elasticsearch HTTP 응답을 읽는 버퍼다. 오류를 분석할 때는 전송한 로그 요청 크기와 bulk 응답 크기를 나눠 살펴볼 수 있다. 버퍼 조정 대상은 사용한 Fluent Bit 버전의 응답 처리 방식에 따라 결정된다.

예를 들어 1M 같은 더 큰 값을 시험할 수 있지만, 이것은 조정 후보이며 당시 성공을 입증한 최종 값은 기록에 없다. 무제한 응답 버퍼는 메모리 사용량을 통제하기 어려우므로 기본 해결책으로 두지 않는다.

같은 로그에는 HTTP Status=200 뒤에도 재시도가 남아 있다. HTTP 상태가 성공이어도 bulk 응답의 errors와 각 items를 확인해야 한다. 응답 수신 실패·절단과 문서별 색인 실패를 분리한다. Fluent Bit 응답 버퍼 설명 · Elasticsearch bulk 응답

당시 HTTP 버퍼·bulk 전송·재시도 로그 전체
plain text
[2026/04/18 13:50:01.267] [debug] [http_client] not using http_proxy for header
[2026/04/18 13:50:01.890] [ warn] [http_client] cannot increase buffer: current=512000 requested=544768 max=512000
[2026/04/18 13:50:01.890] [ warn] [output:es:es.0] http_do=-1 URI=/_bulk
[2026/04/18 13:50:01.890] [debug] [out flush] cb_destroy coro_id=9
[2026/04/18 13:50:01.890] [debug] [retry] re-using retry for task_id=0 attempts=7
[2026/04/18 13:50:01.890] [ warn] [engine] failed to flush chunk '1-1776519877.744378164.flb', retry in 395 seconds: task_id=0, input=tail.0 > output=es.0 (out_id=0)
[2026/04/18 13:50:11.188] [debug] [output:es:es.0] task_id=2 assigned to thread #1
[2026/04/18 13:50:11.210] [debug] [upstream] KA connection #171 to elasticsearch-master.logging.svc.cluster.local:9200 is connected
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.224] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.225] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.225] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.225] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.225] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.225] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.225] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.225] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.225] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.225] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.225] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.225] [debug] [out_es] converted_size is 0
[2026/04/18 13:50:11.225] [debug] [http_client] not using http_proxy for header
[2026/04/18 13:50:11.337] [debug] [output:es:es.0] HTTP Status=200 URI=/_bulk
[2026/04/18 13:50:11.338] [debug] [upstream] KA connection #171 to elasticsearch-master.logging.svc.cluster.local:9200 is now available
[2026/04/18 13:50:11.338] [debug] [out flush] cb_destroy coro_id=9
[2026/04/18 13:50:11.338] [debug] [retry] re-using retry for task_id=2 attempts=7
[2026/04/18 13:50:11.338] [ warn] [engine] failed to flush chunk '1-1776519877.857732987.flb', retry in 246 seconds: task_id=2, input=tail.0 > output=es.0 (out_id=0)

5.2 429와 JVM heap 관측

실습 기록에는 429를 조사했다는 설명과, heap.max가 512mb에서 1gb로 바뀐 노드 목록이 있다. 그러나 이 발췌에는 구체적인 429 응답 본문·rejection 사유가 없고, heap 변경 이후 같은 부하에서 오류가 사라졌다는 검증도 없다.

heap 변경 전후로 기록한 노드 상태
plain text
elasticsearch@elasticsearch-master-0:~$ curl -u "elastic:<REDACTED_PASSWORD>" -k "https://localhost:9200/_cat/nodes?v&h=name,heap.percent,heap.max,ram.percent"
name                   heap.percent heap.max ram.percent
elasticsearch-master-1           55    512mb          92
elasticsearch-master-2           39    512mb          93
elasticsearch-master-0           41    512mb          99
plain text
elasticsearch@elasticsearch-master-0:~$ curl -u "elastic:<REDACTED_PASSWORD>" -k "https://localhost:9200/_cat/nodes?v&h=name,heap.percent,heap.max,ram.percent"
name                   heap.percent heap.max ram.percent
elasticsearch-master-1           11      1gb          75
elasticsearch-master-2           47      1gb          76
elasticsearch-master-0           17      1gb          79

이 수치는 해당 시점의 관측이다. heap.percent·ram.percent를 혼동하지 않고 Elasticsearch의 큐·rejection·GC·CPU와 Fluent Bit 재시도를 같은 시간대로 비교해야 한다. heap을 늘린 사실만으로 400 매핑 오류나 응답 버퍼 문제가 함께 해결되는 것은 아니다.

5.3 HTTP 200 안의 개별 문서 400: text와 object의 충돌

15:44 로그에는 bulk 응답의 errors:true, item status:400, mapper_parsing_exception이 있다. 핵심은 kubernetes.labels.app이 text로 매핑되어 있는데 object 값이 들어왔다는 것이다.

plain text
failed to parse field [kubernetes.labels.app] of type [text]
Preview of field's value: '{kubernetes={io/instance=fluent-bit}}'
Can't get text on a START_OBJECT

같은 필드에 문자열과 객체가 혼재하면 이 오류가 날 수 있다. 라벨의 점을 중첩 구조로 해석한 단계가 어디인지, Fluent Bit filter가 실제로 만든 JSON과 기존 매핑을 비교한다. 버퍼 크기를 늘리는 것만으로 필드 자료형 충돌은 없어지지 않는다.

당시 bulk 항목별 매핑 오류
plain text
[2026/04/18 15:44:41.198] [error] [output:es:es.0] error: Output
{"took":7,"errors":true,"items":[{"create":{"_index":"node-2026.04.18","_id":"rANDoZ0BM27vtEC3_nXc","status":400,"error":{"type":"mapper_parsing_exception","reason":"failed to parse field [kubernetes.labels.app] of type [text] in document with id 'rANDoZ0BM27vtEC3_nXc'. Preview of field's value: '{kubernetes={io/instance=fluent-bit}}'","caused_by":{"type":"illegal_state_exception","reason":"Can't get text on a START_OBJECT at 1:409"}}}},{"create":{"_index":"node-2026.04.18","_id":"rQNDoZ0BM27vtEC3_nXc","status":400,"error":{"type":"mapper_parsing_exception","reason":"failed to parse field [kubernetes.labels.app] of type [text] in document with id 'rQNDoZ0BM27vtEC3_nXc'. Preview of field's value: '{kubernetes={io/instance=fluent-bit}}'","caused_by":{"type":"illegal_state_exception","reason":"Can't get text on a START_OBJECT at 1:310"}}}},{"create":{"_index":"node-2026.04.18","_id":"rgNDoZ0BM27vtEC3_nXc","status":400,"error":{"type":"mapper_parsing_exception","reason":"failed to parse field [kubernetes.labels.app] of type [text] in document with id 'rgNDoZ0BM27vtEC3_nXc'. Preview of field's value: '{kubernetes={io/instance=fluent-bit}}'","caused_by":{"type":"illegal_state_exception","reason":"Can't get text on a START_OBJECT at 1:2311"}}}},{"create":{"_index":"node-2026.04.18","_id":"rwNDoZ0BM27vtEC3_nXc","status":400,"error":{"type":"mapper_parsing_exception","reason":"failed to parse field [kubernetes.labels.app] of type [text] in document with id 'rwNDoZ0BM27vtEC3_nXc'. Preview of field's value: '{kubernetes={io/instance=fluent-bit}}'","caused_by":{"type":"illegal_state_exception","reason":"Can't get text on a START_OBJECT at 1:409"}}}}]}
[2026/04/18 15:44:41.198] [ warn] [engine] failed to flush chunk '1-1776527080.191686265.flb', retry in 9 seconds: task_id=2, input=tail.0 > output=es.0 (out_id=0)

6. 매핑과 ingest pipeline의 정합성을 맞추기

매핑 후보는 kubernetes.labels와 객체형 로그를 flattened로 저장하고, 문자열 로그는 text로 유지하는 방식이었다. flattened는 임의 키가 많은 객체를 한 필드에 담는 데 쓰지만 일반 text 분석이나 숫자별 정밀 매핑을 대신하는 기능은 아니다. 어떤 검색·집계가 필요한지에 맞춰 선택한다. Elasticsearch flattened

아래는 당시 의도를 정리한 후보다. log_json이 이미 있는 경우를 함께 확인하고, 대표 입력을 pipeline simulate로 시험한 다음 새 시험 인덱스에 적용한다.

json
{
  "description": "객체형 log를 log_json으로 분리",
  "processors": [
    {
      "rename": {
        "field": "log",
        "target_field": "log_json",
        "if": "ctx.log instanceof Map && ctx.log_json == null",
        "ignore_missing": true
      }
    }
  ]
}

템플릿은 위 pipeline을 준비한 뒤 실제 출력 인덱스 패턴과 맞춘다.

json
{
  "index_patterns": ["kube-*"],
  "template": {
    "settings": {
      "index.default_pipeline": "log_fix_pipeline"
    },
    "mappings": {
      "properties": {
        "kubernetes": {
          "properties": {
            "labels": { "type": "flattened" }
          }
        },
        "log": { "type": "text" },
        "log_json": { "type": "flattened" }
      }
    }
  }
}

여기서 kube-* 템플릿은 node-*나 logstash-* 인덱스에 자동 적용되지 않는다. 앞 절의 kube. 출력은 prefix를 kube로 맞춘 예시이며, host.의 node-에는 별도 패턴·템플릿이 필요하다. 당시 오류가 node-에서 났는데 템플릿은 kube-*에만 걸려 있던 점도 확인 대상이다.

새 템플릿은 기존 인덱스의 text 필드를 flattened로 소급 변경하지 않는다. 새 시험 인덱스 생성, 기존 데이터 보존·재색인 여부를 따로 계획한다. 같은 키에 문자열·숫자·객체가 섞인 대표 레코드로 색인과 검색을 검증한다.

객체를 toString()으로 바꾸면 구조화 검색에 필요한 정보가 사라지고 유효한 JSON 문자열도 보장되지 않는다. 객체형 필드는 구조를 유지하는 매핑과 pipeline을 우선 검토한다.

매핑 변경은 시험 인덱스에서 검증한 뒤 기존 데이터의 보존·재색인 방식으로 이어진다. 기존 인덱스 삭제는 그 안의 로그 데이터도 함께 제거하는 작업이다.

7. 입력 메모리 초과와 재시도 정책

18:14에는 별도의 입력 버퍼 초과가 관측됐다.

plain text
[2026/04/18 18:14:55.766] [ warn] [input] tail.0 paused (mem buf overlimit - event of size 1066927B exceeded limit 10000000 to 10947678B)

이것은 응답 Buffer_Size와 다른 문제다. 출력 실패로 데이터가 쌓이는 경우, 입력량이 처리량을 넘는 경우, 큰 단일 이벤트가 들어오는 경우를 구분해야 한다. 실습에서는 메모리 증설을 검토했으며 최종 자원값과 지속 수집 결과는 추가 확인 범위다.

메모리 버퍼와 파일시스템 버퍼의 저장 위치·용량·재시작 보존 조건을 정하고, output retry와 저장 한도가 찼을 때의 동작을 확인한다. Retry_Limit False는 재시도 횟수 제한을 없애는 설정이지 디스크·메모리를 무한히 제공하거나 무손실을 보장하는 설정이 아니다. 매핑이 계속 틀리면 재시도해도 같은 오류가 반복된다. Fluent Bit buffering

8. 다음 검증은 수집에서 검색까지 연결한다

재현할 때는 시간 구간과 샘플 로그를 고정하고 Fluent Bit 입력·필터 출력·bulk 응답·Elasticsearch 저장 문서를 연결해 비교한다. TLS·인증 성공, 출력 태그와 인덱스 이름, pipeline 적용, 문서별 실패와 재시도 적체를 순서대로 확인한다.

JSON 로그와 일반 텍스트 로그를 각각 넣어 필요한 필드가 유지되는지 확인하고, Kibana의 데이터 뷰와 검색·집계까지 시험한다. 오류가 줄었다는 사실과 누락·중복이 없다는 사실도 분리한다.

이 실습에서는 Kibana 접근과 일부 문서의 색인을 확인하고, 응답 버퍼·매핑 충돌·입력 버퍼의 문제를 구분했다. 이후 확인할 범위는 매핑 변경 후의 지속 수집, 재시도 적체 해소, 누락·중복과 검색 결과다.