返回到文章

采纳

编辑于

KafkaOffsetMonitor 监控group 问题?

kafka

环境:服务端版本kafka_2.11-0.10.0.1,客户端版本:kafka-clients 0.10.0.1
从百度云盘:https://pan.baidu.com/s/1kUZJrCV 中下载 KafkaOffsetMonitor-assembly-0.3.0-SNAPSHOT.jar,

启动监控程序,执行命令:java -cp KafkaOffsetMonitor-assembly-0.3.0-SNAPSHOT.jar com.quantifind.kafka.offsetapp.OffsetGetterWeb --offsetStorage kafka --zk d0:5181,d1:5181,d2:5181 --port 9986 --refresh 5.seconds --retain 2.days

启动消费者线程,代码如下:

    public static void main(String[] args) {
        Properties props = new Properties();
        props.put("bootstrap.servers", "d0:9092,d1:9092,d2:9092");
//        props.put("zookeeper.connect", "192.168.0.20:5181");
        props.put("auto.offset.reset", "earliest");
        props.put("group.id", "seamus-test");
        props.put("enable.auto.commit", "false");
        props.put("auto.commit.interval.ms", "1000");
        props.put("session.timeout.ms", "30000");
        props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
        props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");

        KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props);
        consumer.subscribe(Arrays.asList("seamus-test"));
        while (true) {
            ConsumerRecords<String, String> records = consumer.poll(1);
            for (ConsumerRecord<String, String> record : records) {
                logger.debug("offset = {}, key = {}, value = {}", record.offset(), record.key(), record.value());
            }

        }
    }

在监控页面中能看到topic,

screenshot

为什么看不到group?