Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the latest offsets in SSL Enabled Kafka via CMD

Tags:

apache-kafka

I have being using the below CMD to get the latest offsets in from a Kafka Queue which has plain-text port open

kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list server:9092 --topic sample_topic --time -1

But, now we only have the SSL port open, so I tried passing the SSL details as a property file

kafka-run-class.sh kafka.tools.GetOffsetShell --broker-list server:9093 --topic sample_topic --time -1 --consumer-config /path/to/file

Getting the below error -

Exception in thread "main" joptsimple.UnrecognizedOptionException: consumer-config is not a recognized option

How do I pass the SSL details to this command? These are all the available arguments for kafka-run-class.sh kafka.tools.GetOffsetShell

--broker-list <String: hostname:and port,...,hostname:port>                
--max-wait-ms <Integer: ms>            
--offsets <Integer: count>             
--partitions <String: partition ids>   
--time <Long: timestamp/-1(latest)/-2             
--topic <String: topic>
like image 403
Venkata Avatar asked Aug 27 '19 21:08

Venkata


People also ask

Does Kafka keep track of offset?

Defining Kafka Consumer Offset The consumer offset is a way of tracking the sequential order in which messages are received by Kafka topics. Keeping track of the offset, or position, is important for nearly all Kafka use cases and can be an absolute necessity in certain instances, such as financial services.

Which consumer in Kafka will commit the current offset?

By default, as the consumer reads messages from Kafka, it will periodically commit its current offset (defined as the offset of the next message to be read) for the partitions it is reading from back to Kafka.

What is Kafka record offset?

OFFSET IN KAFKA The offset is a unique id assigned to the partitions, which contains messages. The most important use is that it identifies the messages through id, which are available in the partitions. In other words, it is a position within a partition for the next message to be sent to a consumer.

What is end offset in Kafka?

Kafka guarantees message ordering in a partition. The log end offset is the offset of the last message written to a log. The high watermark offset is the offset of the last message that was successfully copied to all of the log's replicas.


1 Answers

Unfortunately kafka.tools.GetOffsetShell only supports PLAINTEXT connection. This tools is not used a lot and nobody has bothered updating it.

Depending on your use case, you have a few options:

  • Use the kafka-consumer-groups.sh tool: Assuming you have a consumer group consuming from that topic, this tool display the log end offsets of each partitions

  • Patch kafka.tools.GetOffsetShell: It's realtively easy to add support to secured connections bby reusing logic from the other tool. If you do so, consider sending a patch to Kafka =)

  • Write a tiny tool that calls Consumer.endOffsets()

  • Use kafka.tools.DumpLogSegments: As a last resort this tool can also be used to find the last offset
like image 195
Mickael Maison Avatar answered Oct 11 '22 18:10

Mickael Maison