kafkactl icon indicating copy to clipboard operation
kafkactl copied to clipboard

message separator for consume operation

Open Winand opened this issue 5 months ago • 2 comments

I want to filter multiline messages by substring. Now I use key-value separator to tell awk where a new message begins, because my keys are empty. But I think this is not a robust solution.

DATE="2025-07-06T04|2025-07-06T07"
kafkactl consume my_topic --from-beginning --exit -k -s '~~' | awk "/$DATE/" RS='~~' ORS='\n\n'

Winand avatar Jul 08 '25 09:07 Winand

Hey @Winand,

How about using -o json to format the message as json and pipe that to jq to select what you need?

Cheers, Dirk

d-rk avatar Jul 08 '25 15:07 d-rk

I've thought about it and I think it's a good solution. But it would be nice to have a custom message separator to distinguish multiline messages from each other without additional tools.

Winand avatar Jul 08 '25 19:07 Winand