Why `pbm *` is not using the server's timezone?

Is there a way to make the pbm logs to honor the server’s timezone?
This eases correlating the events shown there with the journalctl -u pbm-agent.

Example: the server (where the the mongod and pbm-agent are running) is on GMT-3. The pbm is also being run at GMT-3.

Here is how the pbm logs looks:

[feng.sian@DSAGIMOGDBSP01 ~]$ pbm logs
...
2021-02-26T12:50:22Z I [rs-dev-00/DSAGIMOGDBSP01.axabr.ad:27001] [backup/2021-02-26T12:50:05Z] backup started
2021-02-26T12:50:25Z I [rs-dev-00/DSAGIMOGDBSP01.axabr.ad:27001] [backup/2021-02-26T12:50:05Z] mongodump finished, waiting for the oplog
2021-02-26T12:50:30Z I [rs-dev-00/DSAGIMOGDBSP01.axabr.ad:27001] [backup/2021-02-26T12:50:05Z] backup finished
2021-02-26T12:51:27Z I [rs-dev-00/DSAGIMOGDBSP01.axabr.ad:27001] got command restore [name: 2021-02-26T12:51:27.166184056Z, backup name: 2021-02-25T18:43:59Z] <ts: 1614343887>
2021-02-26T12:51:27Z I [rs-dev-00/DSAGIMOGDBSP01.axabr.ad:27001] got epoch {1614343830 1}
2021-02-26T12:51:27Z I [rs-dev-00/DSAGIMOGDBSP01.axabr.ad:27001] [restore/2021-02-25T18:43:59Z] restore started
[feng.sian@DSAGIMOGDBSP01 ~]$ 

All these timestamps are on “Zulu TZ” - but the server is on GMT-3:

[feng.sian@DSAGIMOGDBSP01 ~]$ ls -ld /etc/localtime
lrwxrwxrwx. 1 root root 39 Dec 20  2019 /etc/localtime -> ../usr/share/zoneinfo/America/Sao_Paulo
[feng.sian@DSAGIMOGDBSP01 ~]$ 

and the journalctl -u pbm-agent:

[feng.sian@DSAGIMOGDBSP01 ~]$ journalctl -u pbm-agent
...
Feb 26 09:51:30 DSAGIMOGDBSP01 pbm-agent[107868]: 2021-02-26T09:51:30.612-0300        creating collection admin.pbmRUsers using option>
Feb 26 09:51:30 DSAGIMOGDBSP01 pbm-agent[107868]: 2021-02-26T09:51:30.629-0300        restoring admin.pbmRUsers from archive on stdin
Feb 26 09:51:30 DSAGIMOGDBSP01 pbm-agent[107868]: 2021-02-26T09:51:30.631-0300        using 10 insertion workers
Feb 26 09:51:31 DSAGIMOGDBSP01 pbm-agent[107868]: 2021-02-26T09:51:31.083-0300        restoring indexes for collection admin.pbmRUsers>
[feng.sian@DSAGIMOGDBSP01 ~]$

There, the timestamps are correctly localized to the server timezone.

1 Like

Hello.

It was a design decision to use UTC time. One key reason is to avoid encouraging user misunderstandings or mistakes when replica set nodes are in different timezones. This is a requirement for not just some but a lot of users.

Having said that though there is a logging function within the “mongodump” and “mongorestore” libraries that leaves the system logger with defaults, so those lines in the pbm-agent log are coming out with local time.

If we change anything it will be to replace the logger to get UTC everywhere.

1 Like