edenhill / kcat

Generic command line non-JVM Apache Kafka producer and consumer
Other
5.45k stars 484 forks source link

Filter by header #348

Open andrewthad opened 3 years ago

andrewthad commented 3 years ago

It would be useful to, in a consuming context, be able to filter by message headers. I imagine the syntax being something like this:

kafkacat -C -b example.com:9092  -G myexamplegroup -H foo=bar -H baz=bang -t mytopic

The format for key-value pairs would be the same as for the -H flag in the producer context, and the only matching strategy would be exact byte-for-byte matching (no case sensitivity, no regex, no locale-sensitive matching, etc.) implemented by memcmp.

The argument against such a flag is that it's possible to accomplish something similar with grep. However, using grep to do this has these disadvantages:

andrewthad commented 2 years ago

I'm still interested in adding support for this if maintainers believe that kafkacat is a good place for this logic to live.

amterp commented 3 weeks ago

Would be very keen on this feature! I recently discovered kcat and was hoping this was already supported, but seems I'm not in luck.

I'm dealing with quite large messages so being able to filter by header and thus not needing to deserialize all the non-matching messages would be a big win.