아래는 ZooKeeper 기반 구성 기록이다. Kafka 4.0 부터 ZooKeeper 가 제거돼
zookeeper.connect는 더 이상 쓰지 않는다.
현행 버전 구성은 Kafka 4.3.1 설치 가이드 (KRaft) 를 볼 것.
3.x 이하를 운영 중이라면 이 문서가 그대로 유효하다.
- Socket Server Settings
listeners=PLAINTEXT://dist01.haedongg.net:9092- Zookeeper
zookeeper.connect:2181=dist01.haedongg.net,dist02.haedongg.net:2181,dist03.haedongg.net:2181
- 고객사 마다 bash_profile 로 설정해서 관리
############################# Server Basics #############################
# 서버마다 유니크한 정수 값을 가져야한다.
broker.id=1
############################# Socket Server Settings #############################
# Broker 가 사용하는 호스트와 포트
listeners=PLAINTEXT://dist01.haedongg.net:9092
# Producer와 Consumer가 접근하는 호스트와 포트
advertised.listeners=PLAINTEXT://dist01.haedongg.net:9092
#listener.security.protocol.map=PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL
# 네트워크 요청 처리 스레드
num.network.threads=3
# IO 발생 시 생기는 스레드 수
num.io.threads=8
# 소켓 서버가 사용하는 송수신 버퍼
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
# The maximum size of a request that the socket server will accept (protection against OOM)
socket.request.max.bytes=104857600
############################# Log Basics #############################
# Broker가 받은 데이터 관리를 위한 저장 공간
log.dirs=/home/kafka/data
# 토픽 당 파티션의 수. 값 만큼 병렬 처리 가능하고, 파일 수도 늘어남.
num.partitions=1
# The number of threads per data directory to be used for log recovery at startup and flushing at shutdown.
# This value is recommended to be increased for installations with data dirs located in RAID array.
num.recovery.threads.per.data.dir=1
############################# Internal Topic Settings #############################
# The replication factor for the group metadata internal topics "__consumer_offsets" and "__transaction_state"
# For anything other than development testing, a value greater than 1 is recommended to ensure availability such as 3.
# 토픽에 설정된 replication의 인수가 지정한 값보다 크면 새로운 토픽을 생성하고 작을 경우 브로커의 숫자와 같게 된다.
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1
############################# Log Flush Policy #############################
# The number of messages to accept before forcing a flush of data to disk
#log.flush.interval.messages=10000
# The maximum amount of time a message can sit in a log before we force a flush
#log.flush.interval.ms=1000
############################# Log Retention Policy #############################
# 수집 데이터 파일 삭제 주기. (시간, 168h=7days)
log.retention.hours=168
# A size-based retention policy for logs. Segments are pruned from the log unless the remaining
# segments drop below log.retention.bytes. Functions independently of log.retention.hours.
#log.retention.bytes=1073741824
# 토필별 수집 데이터 포관 파일의 크기. 파일 크기를 초과하면 새로운 파일이 생성 됨.
log.segment.bytes=1073741824
# 수집 데이터 파일 삭제 여부 확인 주기 (밀리초, 300000ms=5min)
log.retention.check.interval.ms=300000
# 삭제 대상 수집 데이터 파일의 처리 방법. (delete=삭제, compact=불필요 내용만 제거)
log.cleanup.policy=delete
# 수집 데이터 파일 삭제를 위한 스레드 수
log.cleaner.threads=1
message.max.bytes=1048576
############################# Zookeeper #############################
# Zookeeper connection string (see zookeeper docs for details).
# This is a comma separated host:port pairs, each corresponding to a zk
# server. e.g. "127.0.0.1:3000,127.0.0.1:3001,127.0.0.1:3002".
# You can also append an optional chroot string to the urls to specify the
# root directory for all kafka znodes.
zookeeper.connect=dist01.haedongg.net:2181,dist02.haedongg.net:2181,dist03.haedongg.net:2181
# Timeout in ms for connecting to zookeeper
zookeeper.connection.timeout.ms=6000
############################# Group Coordinator Settings #############################
# The following configuration specifies the time, in milliseconds, that the GroupCoordinator will delay the initial consumer rebalance.
# The rebalance will be further delayed by the value of group.initial.rebalance.delay.ms as new members join the group, up to a maximum of max.poll.interval.ms.
# The default value for this is 3 seconds.
# We override this to 0 here as it makes for a better out-of-the-box experience for development and testing.
# However, in production environments the default value of 3 seconds is more suitable as this will help to avoid unnecessary, and potentially expensive, rebalances during application startup.
group.initial.rebalance.delay.ms=0
# zookeeper admin server configuration
# e.g. http://host.name:8000/commands/stat
admin.enableServer=true
admin.serverPort=8000
admin.commandURL=/commands
############################# Server Basics #############################
# The id of the broker. This must be set to a unique integer for each broker.
#broker.id=10
broker.id.generation.enable=true
############################# Socket Server Settings #############################
listeners=PLAINTEXT://kafka03.haedongg.net:9092
advertised.listeners=PLAINTEXT://kafka03.haedongg.net:9092
# The number of threads that the server uses for receiving requests from the network and sending responses to the network
num.network.threads=3
# The number of threads that the server uses for processing requests, which may include disk I/O
num.io.threads=8
# The send buffer (SO_SNDBUF) used by the socket server
socket.send.buffer.bytes=102400
# The receive buffer (SO_RCVBUF) used by the socket server
socket.receive.buffer.bytes=102400
# The maximum size of a request that the socket server will accept (protection against OOM)
socket.request.max.bytes=104857600
############################# Log Basics #############################
# A comma separated list of directories under which to store log files
log.dirs=/xvdb/kafka/logs
# The default number of log partitions per topic. More partitions allow greater
# parallelism for consumption, but this will also result in more files across
# the brokers.
num.partitions=1
# The number of threads per data directory to be used for log recovery at startup and flushing at shutdown.
# This value is recommended to be increased for installations with data dirs located in RAID array.
num.recovery.threads.per.data.dir=1
############################# Internal Topic Settings #############################
# The replication factor for the group metadata internal topics "__consumer_offsets" and "__transaction_state"
# For anything other than development testing, a value greater than 1 is recommended to ensure availability such as 3.
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1
# to resieve big size messages
message.max.bytes=67108864
fetch.max.bytes=67108864
############################# Log Flush Policy #############################
# The minimum age of a log file to be eligible for deletion due to age
log.retention.hours=72
# to the retention policies
log.retention.check.interval.ms=300000
############################# Zookeeper #############################
# root directory for all kafka znodes.
zookeeper.connect=kafka01.haedongg.net:2181,kafka02.haedongg.net:2181,kafka03.haedongg.net:2181
# Timeout in ms for connecting to zookeeper
zookeeper.connection.timeout.ms=18000
##################### Confluent Metrics Reporter #######################
# Confluent Control Center and Confluent Auto Data Balancer integration
#
# Uncomment the following lines to publish monitoring data for
# Confluent Control Center and Confluent Auto Data Balancer
# If you are using a dedicated metrics cluster, also adjust the settings
# to point to your metrics kakfa cluster.
#metric.reporters=io.confluent.metrics.reporter.ConfluentMetricsReporter
#confluent.metrics.reporter.bootstrap.servers=localhost:9092
#
# Uncomment the following line if the metrics cluster has a single broker
#confluent.metrics.reporter.topic.replicas=1
############################# Group Coordinator Settings #############################
# The following configuration specifies the time, in milliseconds, that the GroupCoordinator will delay the initial consumer rebalance.
# The rebalance will be further delayed by the value of group.initial.rebalance.delay.ms as new members join the group, up to a maximum of max.poll.interval.ms.
# The default value for this is 3 seconds.
# We override this to 0 here as it makes for a better out-of-the-box experience for development and testing.
# However, in production environments the default value of 3 seconds is more suitable as this will help to avoid unnecessary, and potentially expensive, rebalances during application startup.
Kafka data directory 예시
# Generic jvm settings you want to add
if [ -z "$KAFKA_OPTS" ]; then
KAFKA_OPTS="-javaagent:/opt/kafka/libs/jmx_prometheus_javaagent.jar=9000:/opt/kafka/config/kafka-metrics.yml"
fi
# ============================================================
# kafka-metrics.yml
# Kafka 3.9.x — ZooKeeper 모드 (deprecated, 마지막 ZK 지원 버전)
#
# 출처:
# - prometheus/jmx_exporter kafka-2_0_0.yml (공식)
# - strimzi/strimzi-kafka-operator kafka-metrics.yaml (운영 검증)
# - 3.x 추가 패턴 (listener/TLS/cipher 메트릭)
# ============================================================
lowercaseOutputName: true
lowercaseOutputLabelNames: true
rules:
# ══════════════════════════════════════════════════════════
# 1. 특수 케이스 — 가장 구체적인 패턴 먼저
# ══════════════════════════════════════════════════════════
# clientId + topic + partition 포함 (producer/consumer fetch 메트릭)
- pattern: 'kafka.server<type=(.+), name=(.+), clientId=(.+), topic=(.+), partition=(.*)><>Value'
name: kafka_server_$1_$2
type: GAUGE
labels:
clientId: "$3"
topic: "$4"
partition: "$5"
# clientId + brokerHost + brokerPort (replica fetcher 메트릭)
- pattern: 'kafka.server<type=(.+), name=(.+), clientId=(.+), brokerHost=(.+), brokerPort=(.+)><>Value'
name: kafka_server_$1_$2
type: GAUGE
labels:
clientId: "$3"
broker: "$4:$5"
# ── 3.x 신규: TLS cipher/protocol 연결 정보 ──────────────
- pattern: 'kafka.server<type=(.+), cipher=(.+), protocol=(.+), listener=(.+), networkProcessor=(.+)><>connections'
name: kafka_server_$1_connections_tls_info
type: GAUGE
labels:
cipher: "$2"
protocol: "$3"
listener: "$4"
networkProcessor: "$5"
# ── 3.x 신규: 클라이언트 소프트웨어 버전 정보 ──────────
- pattern: 'kafka.server<type=(.+), clientSoftwareName=(.+), clientSoftwareVersion=(.+), listener=(.+), networkProcessor=(.+)><>connections'
name: kafka_server_$1_connections_software
type: GAUGE
labels:
clientSoftwareName: "$2"
clientSoftwareVersion: "$3"
listener: "$4"
networkProcessor: "$5"
# ── 3.x 신규: listener + networkProcessor 포함 COUNTER ──
- pattern: 'kafka.server<type=(.+), listener=(.+), networkProcessor=(.+)><>(.+-total):'
name: kafka_server_$1_$4
type: COUNTER
labels:
listener: "$2"
networkProcessor: "$3"
# ── 3.x 신규: listener + networkProcessor 포함 GAUGE ────
- pattern: 'kafka.server<type=(.+), listener=(.+), networkProcessor=(.+)><>(.+):'
name: kafka_server_$1_$4
type: GAUGE
labels:
listener: "$2"
networkProcessor: "$3"
- pattern: 'kafka.server<type=(.+), listener=(.+), networkProcessor=(.+)><>(.+-total)'
name: kafka_server_$1_$4
type: COUNTER
labels:
listener: "$2"
networkProcessor: "$3"
- pattern: 'kafka.server<type=(.+), listener=(.+), networkProcessor=(.+)><>(.+)'
name: kafka_server_$1_$4
type: GAUGE
labels:
listener: "$2"
networkProcessor: "$3"
# ══════════════════════════════════════════════════════════
# 2. Percent / MeanRate 계열
# ══════════════════════════════════════════════════════════
# 예: kafka.server<type=KafkaRequestHandlerPool,
# name=RequestHandlerAvgIdlePercent><>MeanRate
- pattern: 'kafka.(\w+)<type=(.+), name=(.+)Percent\w*><>MeanRate'
name: kafka_$1_$2_$3_percent
type: GAUGE
- pattern: 'kafka.(\w+)<type=(.+), name=(.+)Percent\w*><>Value'
name: kafka_$1_$2_$3_percent
type: GAUGE
- pattern: 'kafka.(\w+)<type=(.+), name=(.+)Percent\w*, (.+)=(.+)><>Value'
name: kafka_$1_$2_$3_percent
type: GAUGE
labels:
"$4": "$5"
# ══════════════════════════════════════════════════════════
# 3. PerSec 계열 → COUNTER (누적 카운터)
# Count 속성 = 누적값이므로 COUNTER 타입
# ══════════════════════════════════════════════════════════
- pattern: 'kafka.(\w+)<type=(.+), name=(.+)PerSec\w*, (.+)=(.+), (.+)=(.+)><>Count'
name: kafka_$1_$2_$3_total
type: COUNTER
labels:
"$4": "$5"
"$6": "$7"
- pattern: 'kafka.(\w+)<type=(.+), name=(.+)PerSec\w*, (.+)=(.+)><>Count'
name: kafka_$1_$2_$3_total
type: COUNTER
labels:
"$4": "$5"
- pattern: 'kafka.(\w+)<type=(.+), name=(.+)PerSec\w*><>Count'
name: kafka_$1_$2_$3_total
type: COUNTER
# ══════════════════════════════════════════════════════════
# 4. Quota 전용 규칙
# ══════════════════════════════════════════════════════════
- pattern: 'kafka.server<type=(.+), user=(.+), client-id=(.+)><>([a-z-]+)'
name: kafka_server_quota_$4
type: GAUGE
labels:
resource: "$1"
user: "$2"
clientId: "$3"
- pattern: 'kafka.server<type=(.+), client-id=(.+)><>([a-z-]+)'
name: kafka_server_quota_$3
type: GAUGE
labels:
resource: "$1"
clientId: "$2"
- pattern: 'kafka.server<type=(.+), user=(.+)><>([a-z-]+)'
name: kafka_server_quota_$3
type: GAUGE
labels:
resource: "$1"
user: "$2"
# ══════════════════════════════════════════════════════════
# 5. Coordinator 메트릭
# (GroupMetadataManager, TransactionMarkerChannelManager 등)
# ══════════════════════════════════════════════════════════
- pattern: 'kafka.coordinator.(\w+)<type=(.+), name=(.+)><>Value'
name: kafka_coordinator_$1_$2_$3
type: GAUGE
# ══════════════════════════════════════════════════════════
# 6. 일반 GAUGE — Value 속성 (라벨 0~2개)
# ══════════════════════════════════════════════════════════
- pattern: 'kafka.(\w+)<type=(.+), name=(.+), (.+)=(.+), (.+)=(.+)><>Value'
name: kafka_$1_$2_$3
type: GAUGE
labels:
"$4": "$5"
"$6": "$7"
- pattern: 'kafka.(\w+)<type=(.+), name=(.+), (.+)=(.+)><>Value'
name: kafka_$1_$2_$3
type: GAUGE
labels:
"$4": "$5"
- pattern: 'kafka.(\w+)<type=(.+), name=(.+)><>Value'
name: kafka_$1_$2_$3
type: GAUGE
# ══════════════════════════════════════════════════════════
# 7. Count + Percentile → Summary/Histogram 에뮬레이션
# (레이턴시 분포 — TotalTimeMs, RequestQueueTimeMs 등)
# ══════════════════════════════════════════════════════════
- pattern: 'kafka.(\w+)<type=(.+), name=(.+), (.+)=(.+), (.+)=(.+)><>Count'
name: kafka_$1_$2_$3_count
type: COUNTER
labels:
"$4": "$5"
"$6": "$7"
# NthPercentile → quantile 라벨
# 예: 99thPercentile → {quantile="0.99"}
- pattern: 'kafka.(\w+)<type=(.+), name=(.+), (.+)=(.*), (.+)=(.+)><>(\d+)thPercentile'
name: kafka_$1_$2_$3
type: GAUGE
labels:
"$4": "$5"
"$6": "$7"
quantile: "0.$8"
- pattern: 'kafka.(\w+)<type=(.+), name=(.+), (.+)=(.+)><>Count'
name: kafka_$1_$2_$3_count
type: COUNTER
labels:
"$4": "$5"
- pattern: 'kafka.(\w+)<type=(.+), name=(.+), (.+)=(.*)><>(\d+)thPercentile'
name: kafka_$1_$2_$3
type: GAUGE
labels:
"$4": "$5"
quantile: "0.$6"
- pattern: 'kafka.(\w+)<type=(.+), name=(.+)><>Count'
name: kafka_$1_$2_$3_count
type: COUNTER
- pattern: 'kafka.(\w+)<type=(.+), name=(.+)><>(\d+)thPercentile'
name: kafka_$1_$2_$3
type: GAUGE
labels:
quantile: "0.$4"