You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@kafka.apache.org by Spico Florin <sp...@gmail.com> on 2016/06/08 12:16:32 UTC
Monitor the lag for the consumers that are assigned to partitions topic
Hello!
I'm working with Kafka 0.9.1 new consumer API.
The consumer is manually assigned to a partition. For this consumer I would
like to see its progress (meaning the lag).
Since I added the group id consumer-tutorial as property, I assumed that I
can use the command
bin/kafka-consumer-groups.sh --new-consumer --describe --group
consumer-tutorial-group --bootstrap-server localhost:9092
(as explained here
*http://www.confluent.io/blog/tutorial-getting-started-with-the-new-apache-kafka-0.9-consumer-client
<http://www.confluent.io/blog/tutorial-getting-started-with-the-new-apache-kafka-0.9-consumer-client>)*
Unfortunately, my group is not shown by the above command. Therefore I
cannot monitor the progress of my conusmer (its lag).
How can I monitor the lag in the above described scenario (manually
assigned partition)?
I look forward for your answers.
Thanks,
Florin
P.S. I'm using the below code for testing:
Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092");
props.put("group.id", "consumer-tutorial");
props.put("key.deserializer", StringDeserializer.class.getName());
props.put("value.deserializer", StringDeserializer.class.getName());
KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props);
*String topic = "my-topic";*
* TopicPartition topicPartition = new TopicPartition(topic, 0);*
* consumer.assign(Arrays.asList(topicPartition));*
consumer.seekToBeginning(topicPartition);
try {
while (true) {
ConsumerRecords<String, String> records = consumer.poll(1000);
for (ConsumerRecord<String, String> record : records)
System.out.println(record.offset() + ": " + record.value());
consumer.commitSynch();
}
} finally {
consumer.close();
}
Fwd: Monitor the lag for the consumers that are assigned to
partitions topic
Posted by Spico Florin <sp...@gmail.com>.
Hello!
I'm working with Kafka 0.9.1 new consumer API.
The consumer is manually assigned to a partition. For this consumer I would
like to see its progress (meaning the lag).
Since I added the group id consumer-tutorial as property, I assumed that I
can use the command
bin/kafka-consumer-groups.sh --new-consumer --describe --group
consumer-tutorial --bootstrap-server localhost:9092
(as explained here
*http://www.confluent.io/blog/tutorial-getting-started-with-the-new-apache-kafka-0.9-consumer-client
<http://www.confluent.io/blog/tutorial-getting-started-with-the-new-apache-kafka-0.9-consumer-client>)*
Unfortunately, my group is not shown by the above command. Therefore I
cannot monitor the progress of my conusmer (its lag).
How can I monitor the lag in the above described scenario (manually
assigned partition)?
I look forward for your answers.
Thanks,
Florin
P.S. I'm using the below code for testing:
Properties props = new Properties();
props.put("bootstrap.servers", "localhost:9092");
props.put("group.id", "consumer-tutorial");
props.put("key.deserializer", StringDeserializer.class.getName());
props.put("value.deserializer", StringDeserializer.class.getName());
KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props);
*String topic = "my-topic";*
* TopicPartition topicPartition = new TopicPartition(topic, 0);*
* consumer.assign(Arrays.asList(topicPartition));*
consumer.seekToBeginning(topicPartition);
try {
while (true) {
ConsumerRecords<String, String> records = consumer.poll(1000);
for (ConsumerRecord<String, String> record : records)
System.out.println(record.offset() + ": " + record.value());
consumer.commitSynch();
}
} finally {
consumer.close();
}