Tailing logs with GCE and stackdriver

google-cloud-platformgoogle-stackdriverkubernetes

I have a running Kubernetes cluster that aggregates it's logfiles in stackdriver and would like to tail the aggregated logs on the command line. But so far I am only able to view the json stream float by in the web interface or fetch historic logging data with a command like gcloud beta logging read 'resource.type="container" jsonPayload.service:("my-service") timestamp >= "2017-06-22T16:00:00+02:00"' --format=json.

Is there no way in GCE for me to build an aggregated real time view of the current log entries, like you would get from a tail -f?

Best Answer

The only realtime like thing that you could use is to create a sink from Stackdriver to Pub/Sub and create a consumer that will receive in almost real time, messages from SD; the other options are based on sending chunks of information every X time and won't be as near realtime as you would like.

You can read about exporting logs in Googles SD documentation for that matter.

I hope this information can help you solve your issue.

Regards! -JP