top | item 27822856

(no title)

jimpudar | 4 years ago

How does it handle merging log files that are in different time zones? I wrote a small script to merge log files from lots of different network appliances a long time ago, it was extremely useful for debugging problems that occurred across our distributed system. The most unfortunate part was that the appliances all logged in local time and didn't include their UTC offsets in the timestamps :(

discuss

order

tstack|4 years ago

Timezones are not automatically handled by lnav at the moment, which isn't great. Timestamps are parsed and treated as UTC internally, which usually works out fine. You can manually adjust all of the timestamps for a file using the ":adjust-log-time" command:

https://docs.lnav.org/en/latest/commands.html#adjust-log-tim...

That can be useful for doing minor alignments if clocks are slightly out of sync or doing timezone adjustments.

You can also adjust the time programmatically by updating the "time_offset" column in the "lnav_file" table:

https://docs.lnav.org/en/latest/sqltab.html#lnav-file

Sorry I don't have any examples written up to illustrate this at the moment...

jimpudar|4 years ago

Thanks, I see. At least with `:adjust-log-time` you can make it work!

With my old log merging program, you had to supply a regex with groups for the different timezone components and optionally a UTC offset. That worked really well but was a pain to set up. Typically I was using it to look at the same format of files all the time though, so in practice it wasn't that bad.

I'm not really a C/C++ person but maybe I'll try and hack on lnav a bit and see if I can figure out how to add timezone support.