kcat icon indicating copy to clipboard operation
kcat copied to clipboard

Show message timestamp as UTC ISO8601 format

Open MitchelNijdam-Rockstars opened this issue 5 years ago • 5 comments

Although I think currently the %T format string token just prints the unix epoch timestamp as read from kafka, for quick debug purposes it would be very useful to have a timestamp in more readable format, for example ISO8601 in UTC. Currently I have to copy paste the timestamps to a converter in order to make sense of it.

If there already is an alternative I'm happy to hear about it!

MitchelNijdam-Rockstars avatar Jul 01 '19 12:07 MitchelNijdam-Rockstars

That does make sense.

As a workaround you can use jq to reformat the timestamp: https://stackoverflow.com/questions/36853202/jq-dates-and-unix-timestamps

edenhill avatar Oct 07 '19 09:10 edenhill

I have done a quick change #216 to display human readable form next to epoch. You can build it from https://github.com/wkujawa/kafkacat

Example for format 'Timestamp: %T': Timestamp: 1576098689443 (Wed 2019-12-11 22:11:29.443 CET)

It should be new format specifier but that way is good for me. Feel free to do whatever you like with it. I can also modify it further.

wkujawa avatar Dec 14 '19 10:12 wkujawa

Example of the workaround mentioned by @edenhill:

kcat -C \
  -b $KAFKA_BROKER \
  -t $KAFKA_TOPIC \
  -o beginning \
  -J \
  -e \
| jq '.ts |= (. / 1000 | strftime("%Y-%m-%d %H:%M:%S"))'

Edit: fixed according to the comments directly below

fletchgqc avatar Jun 14 '22 10:06 fletchgqc

Example of the workaround mentioned by @edenhill:

kcat -C \
  -b $KAFKA_BROKER \
  -t $KAFKA_TOPIC \
  -o beginning \
  -J \
  -e \
| jq '.ts |= (. / 1000 | strftime("%Y-%m-%d %H:%m:%S"))'

@fletchgqc @edenhill Thanks a lot. btw. you probably meant "%Y-%m-%d %H:%M:%S"

raphaelsolarski avatar Aug 01 '22 15:08 raphaelsolarski

For anyone who, like me, has trouble seeing the difference: the original comment by @fletchgqc erroneously uses m (month) not M (minute) for the time format

--------------Δ----
"%Y-%m-%d %H:%m:%S"
"%Y-%m-%d %H:%M:%S

tbrv avatar Jul 26 '23 07:07 tbrv