darold / pgbadger

A fast PostgreSQL Log Analyzer
http://pgbadger.darold.net/
PostgreSQL License
3.49k stars 349 forks source link

Wrong time displayed on Graphs x-axis whereas times extracted from logs are correct #750

Closed bbourgier closed 1 year ago

bbourgier commented 1 year ago

Hi,

There is a 2 hours time discrepancy between:

I attach screenshots for your comprehension.

Thanks in advance for your analysis and answers.

Bertrand pgBadger Graph Times Discrepancies pgBadger Windows Server System Time postgreSQL Last Log File

darold commented 1 year ago

Yes, the problem is that the timestamps shown in the Javascript graphs are based on your client host timezone and not the one of the log file. You can adjust the timezone for those graphs when building pgbadger reports using the -Z or --timezone option at command line. See pgbadger --help for usage.

bbourgier commented 1 year ago

Hi,

Ok I can do as you say and set --timezone parameter manually. As my system timezone is "Europe/Paris", this is GMT+2 so I put: --timezone +2

this means my system time is GMT+2

And this fixes the JS graphs. See the screenshot. pgBadger Graph Times OK with timezone param

However I was wondering why this does not work WITHOUT this parameter.

As my postgresql log lines are tagged with a timezone: 2022-09-09 00:10:01.034 CEST [525932]: [2-1] user=... And as CEST timezone is GMT+2 as well This should be possible to select the x-axis time scale for the JS graphs without having to offset manually. The drawback being that this offset may change depending on DST...

Well, thank you in any case for your answer.

Bertrand

darold commented 1 year ago

This is just because sometimes there is no timezone information and some other time the client is not at the same timezone and historically pgbadger doesn't take care of the timezone in the logs. Maybe this could be improved by using an advanced Date/Time Perl module but this is not in the pgbadger development policy.