0

I use kafkacat to see the header, but it returns

 % ERROR: Unsupported formatter: %h 

My kafkacat is 1.3, installed by apt-get install kafkacat

The full command I use is:

kafkacat -b localhost:9092 -t dlq_file_sink_03 -C -o-1 -c1 \
  -f '\nKey (%K bytes): %k
  Value (%S bytes): %s
  Timestamp: %T
  Partition: %p
  Offset: %o
  Headers: %h\n'

The above works without %h. %H also does not work.

Holm
  • 2,987
  • 3
  • 27
  • 48

1 Answers1

1

This was added to kafkacat in recent versions. If the version you have does not support it the your other option is to build it yourself or run the Docker image.

Robin Moffatt
  • 30,382
  • 3
  • 65
  • 92
  • is the reading header feature included in the latest docker image? I tested days ago but it didn't work. I may try specifying 5.2.2 later. – Holm Jul 08 '19 at 13:27
  • when building kafkacat locally by running `make` after `configure` success, it returns ``` kafkacat.h:105:9: error: unknown type name ‘rd_kafka_headers_t’ rd_kafka_headers_t *headers; ^~~~~~~~~~~~~~~~~~ mklove/Makefile.base:77: recipe for target 'kafkacat.o' failed make: *** [kafkacat.o] Error 1 ``` – Holm Jul 08 '19 at 13:28
  • @AkiraSendoh You need to upgrade librdkafka (to v0.11.6 or later, preferably v1.1.0). – Edenhill Jul 09 '19 at 21:41
  • 2
    Or you could try the latest docker image: `docker run -it --net=host edenhill/kafkacat:20190709 ... ` – Edenhill Jul 09 '19 at 21:42
  • @Edehill thank you! the container works. I found this version cannot use `-C -o-5` and has to use -G? but I don't find a way to use -G that reads from the beginning. do I have to create a consumer group pointing to the earliest offset in advance? – Holm Jul 10 '19 at 13:44
  • thanks edenhill for the help in the github issue! following is the solution from him: docker run --tty --interactive --rm --net=host \ edenhill/kafkacat:20190709 \ -b localhost:29092 -t kafkacat -o beginning \ -f '\n Value (%S bytes): %s Headers: %h\n' https://github.com/edenhill/kafkacat/issues/191 – Holm Jul 10 '19 at 14:06