logginggoogle-cloud-platformgoogle-kubernetes-enginegoogle-cloud-stackdrivergoogle-cloud-logging

How to view container logs in GKE's Logs Explorer


In my GKE cluster (version v1.21.10-gke.2000) I would like to see output produced by pods/containers as logs in Logs Explorer.

But clicking on Container Logs link in Workloads' Overview tab makes Logs Explorer return 'No data found'. Cloud Logging is enabled (Components: System, Workloads). Cloud Logging API is enabled as well.

What I have tried so far: In another (test) project in a freshly created cluster (version 1.22.8-gke.201) this works correctly, i.e. what kubectl logs returns is also visible in Logs Explorer. The cluster mentioned at the beginning was created long ago and apparently requires some changes - how can I figure out what cluster (or maybe node pool) settings need to be modified to be able to see container logs in Logs Explorer? I would like to avoid creating a new cluster from scratch.


Solution

  • If you can't see any of your logs in Cloud Logging, you could try the instructions here in this document about How to find—and use—your GKE logs with Cloud Logging and find the Make sure you’re collecting GKE logs section.