Kafka console consumer get partition

Consider using a more powerful Kafka command line consumer like kafkacat https://github.com/edenhill/kafkacat/blob/master/README.md

For example, the following command will print the topic, partition, offset and message payload/value for each message consumed:

kafkacat -b <broker> -C -t <topic> -f '%t %p @ %o: %s\n'


For kafka 9 there is nothing out-of-the-box that can print you that info.

According to the code, message formatter gets key and value only.

try {
    formatter.writeTo(msg.key, msg.value, System.out)
}

--property print.key=true allows to print message key.

In kafka 10 there is one more useful param print.timestamp