본문 바로가기
kafka/core

kafka-consumer-groups 명령어로 Consumer Group과 Consumer, Lag 정보 확인

by 개복이 2025. 4. 25.

kafka-consumer-groups 명령어로 Consumer Group과 Consumer, Lag 정보 확인

  • consumer groups는 consumer가 모두 떠나 empty 상태가 되어도 자동으로 삭제되지 않고 일정 기간동안 보관된다.

 

kafka-consumer-groups 명령어

  • Consumer Group list 정보
  • Consumer Group과 Consumer 관계, Partition 등에 대한 상세 정보
  • Consumer Group 삭제
  • Producer가 전송한 Lag Message 지연 Lag 정보

 

Consumer Group 리스트 조회

kafka-consumer-groups --bootstrap-server localhost:9092 --list

 

Consumer Groups가 group_01인 Consumer 1개 생성 후 group_01 상세 확인

Consumer Groups가 group_01인 Consumer 생성

kafka-console-consumer --bootstrap-server localhost:9092 --group group_01 --topic multipart-topic --property print.key=true --property print.partition=true

 

Consumer Groups가 group_01 상세 확인

  • CONSUMER-ID가 모두 console-consumer-182~ 인것을 확인할 수 있다.
kafka-consumer-groups --bootstrap-server localhost:9092 --group group_01 --describe

 

Consumer Groups가 group_01인 Consumer 1개를 더 생성(총 2개) 후 group_01 상세 확인

Consumer Groups가 group_01인 Consumer 생성

kafka-console-consumer --bootstrap-server localhost:9092 --group group_01 --topic multipart-topic --property print.key=true --property print.partition=true

 

Consumer Groups가 group_01 상세 확인

  • rebalancing 수행 후 CONSUMER-ID가 console-consumer-d57~이 파티션 2번을 할당 받았다.
kafka-consumer-groups --bootstrap-server localhost:9092 --group group_01 --describe

 

Consumer Groups가 group_01인 Consumer 1개를 더 생성(총 3개) 후 group_01 상세 확인

Consumer Groups가 group_01인 Consumer 생성

kafka-console-consumer --bootstrap-server localhost:9092 --group group_01 --topic multipart-topic --property print.key=true --property print.partition=true

 

Consumer Groups가 group_01 상세 확인

  • rebalancing 수행 후 CONSUMER-ID가 console-consumer-4bf~이 파티션 1번을 할당 받았다.
kafka-consumer-groups --bootstrap-server localhost:9092 --group group_01 --describe

 

Consumer가 생길 때마다 rebalancing 수행, group_01 상세에서 CONSUMER-ID와 동일한지 확인

  • group_01 상세 확인해서 확인한 CONSUMER-ID와 동일한 것을 확인할 수 있다.

 

생성한 3개의 Consumer가 모두 떠나고 producer 메시지 발행 후 group_01 상세 확인

  • Consumer가 모두 떠났기 때문에 앞에서 살펴본 것과 다르게 CONSUMER-ID, HOST, CLIENT-ID가 나타나지 않는다.

메시지 발행 전

 

메시지 발행 후

  • 총 5개의 메시지를 발행하였고, LOG_END_OFFSET, LAG 등이 쌓인 것을 확인할 수 있다.

댓글