Enable Millisecond Logging in Stackdriver with GKE Cluster

10/19/2018

I have a platform requirement to log a number of different applications living in a GKE cluster (currently logging to Stackdriver via Fluentd-gcp agent) in milliseconds. By default, Stackdriver logs the "receiveTimestamp" in nanoseconds:

receiveTimestamp:  "2018-10-19T16:02:37.147760051Z"  

The actual timestamp in seconds, however:

timestamp:  "2018-10-19T16:02:36Z" 

I know the logging internal to the containers is capturing a more detailed timestamp though:

textPayload:  "2018-10-19T16:02:36,036244860+00:00 ..."

I cannot find anything online on how to enable the timestamp to log a more precise time. I have tried altering the ConfigMap for Fluentd without any success. It may be that I am altering the wrong part of that config file, but at this point, I am just hoping for some GCP expert guidance to point me in the right direction. Thanks in advance.

Cheers!

-- Matthew Bennett
google-cloud-platform
google-kubernetes-engine
stackdriver

1 Answer

10/25/2018

I just noticed in the documentation for the timestamp field:

https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry

A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".

Your application seems to be sending timestamps with a "," instead of a ".". I can imagine it might parse better if your app uses the dot format from the example.

Does that work?

-- Christiaan
Source: StackOverflow