[英]Apache Kafka: How to find out consumer group of a topic?
I am working on Kafka with Spark streaming in Scala.我正在使用 Scala 中的 Spark 流处理 Kafka。 There are multiple topics from which I need to fetch messages.
我需要从多个主题中获取消息。 For that, I need to input consumer group of each topic.
为此,我需要输入每个主题的消费者组。
I have tried following command:我尝试过以下命令:
bin/kafka-consumer-groups.sh --zookeeper localhost:2181 --describe --group group_name
For this, I need to mention consumer group and check whether my topic falls under this group.为此,我需要提及消费者组并检查我的主题是否属于该组。 But I don't know the consumer group value for some topics.
但我不知道某些主题的消费群体价值。
So, is there any command or programmatic way of finding consumer group for a given topic?那么,是否有任何命令或编程方式来查找给定主题的消费者组?
Any help on this would be greatly appreciated.对此的任何帮助将不胜感激。 Thank you
谢谢
You can read data from various topics by specifying the topics.您可以通过指定主题从各种主题中读取数据。 You can simply create a Map of topics.
您可以简单地创建一个主题地图。 Refer to the below link
请参考以下链接
https://www.tutorialspoint.com/apache_kafka/apache_kafka_consumer_group_example.htm https://www.tutorialspoint.com/apache_kafka/apache_kafka_consumer_group_example.htm
There is no Command/API provided by kafka to list consumer groups consuming from a specified topic. kafka 没有提供命令/API 来列出从指定主题消费的消费者组。 Instead you can use a tool developed by yahoo to manage kafka clusters : Yahoo Kafka Manager .
相反,您可以使用 yahoo 开发的工具来管理 kafka 集群: Yahoo Kafka Manager 。 After installing this software and pointing yahoo kafka manager to your kafka cluster, you can view consumer groups consuming from a specified topic.
安装完这个软件,将yahoo kafka manager 指向你的kafka集群后,就可以查看从指定topic消费的consumer group了。
for i in `kafka-consumer-groups --list --bootstrap-server localhost:9092`; do echo $i; (kafka-consumer-groups --describe --bootstrap-server localhost:9092 --group $i 2>&1| grep mytopic); done
这需要一些时间,因为它会检查所有主题,但会告诉哪些消费者群体使用该主题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.