1

I store reports from nodes in puppetdb. I want to check time when reports received from specific node via the following query:

curl -sk http://pdb:8080/v3/reports --data-urlencode 'query=["=", "certname", "host.mydomain.com"]' | grep "receive-time"

i get the following output:

"receive-time" : "2015-12-05T11:57:13.882Z",
"receive-time" : "2015-12-05T11:46:26.826Z",
"receive-time" : "2015-12-05T11:17:15.702Z",
"receive-time" : "2015-12-05T13:13:56.060Z",

So i can conclude that i have 4 reports from 09:32:15 until 11:32:13. and this is wrong ( offset of 2 hours )

At other hand when i query postgresdb backend directly via

select certname,puppet_version,start_time, status_id from reports where certname = 'host.mydomain.com' order by start_time desc; i get different times:

 host.mydomain.com | 3.8.1   | 2015-12-05 13:57:07.079+02 |    2
 host.mydomain.com | 3.8.1   | 2015-12-05 13:46:19.658+02 |    2
 host.mydomain.com | 3.8.1   | 2015-12-05 13:17:07.056+02 |    2
 host.mydomain.dom | 3.8.1   | 2015-12-05 13:13:56.608+02 |    2

And these are correct times for reports. All settings for server timezone where puppetdb runs are correct. All settings for postgresdb are set to the same timezone.

How can i make query via curl report correct time please ?

1 Answers1

1

The capital Z after a time-stamp such as 2015-12-05T11:32:13.718Z stands for Zulu time, UTC.

The other time stamp 2015-12-05 13:57:07.079+02 with the +2 is the time corrected for your local time zone, two hours ahead of UTC.

So they are both correct in the absolute sense, but you need to add two hours to a time-stamp in UTC to match with your watch.

HBruijn
  • 72,524
  • 21
  • 127
  • 192
  • Perfect, is there any reason why it returns query results in Zulu time, and not in my local time zone time ? – Dima Zyuryaev Dec 05 '15 at 12:46
  • When you access the console do you also get time-stamps in UTC or do you get them displayed in local time? – HBruijn Dec 05 '15 at 12:49
  • In postgres console i don`t see any timestamps. I just see there time in correct format which match my timezone exactly – Dima Zyuryaev Dec 05 '15 at 12:53
  • It might have to do with [this](https://ask.puppetlabs.com/question/18559/puppet-pe-20152-timezone/) and the referenced [support ticket](https://tickets.puppetlabs.com/browse/ENTERPRISE-560) where Puppet uses UTC internally and local time conversion is only done in the UI. – HBruijn Dec 05 '15 at 12:55
  • Thank you very much. I will just format output with +2 offset :) There is very nice 'time' library in python for that – Dima Zyuryaev Dec 05 '15 at 12:58
  • Don't overlook the correction for daylight savings time... – HBruijn Dec 05 '15 at 13:01