Announcements
This site is in read only until July 22 as we migrate to a new platform; refer to this community post for more details.
Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Sending application logs to cloud logging

I can't figure out how to send applications logs (those  visible via "kubectl logs pod-ID") to Cloud Logging.

The pods are being run in "default" K8S namespace. According to 

https://cloud.google.com/logging/docs/

docs, GKE sends all application logs to whatever cloud logging routing configured. However, I can't find any of the logs I see via "kubectl logs pod-ID" in cloud logging explorer.

How that can be done?

0 3 3,639
3 REPLIES 3

Hello,

By default AFAIK, GKE sends only cluster related logs, as controlplane logs, pods etc. If you want to get also app logs, try this: https://cloud.google.com/architecture/customizing-stackdriver-logs-fluentd
or to be more sticked with GKE, https://github.com/GoogleCloudPlatform/community/blob/master/archived/kubernetes-engine-customize-fl... 
cheers,
DamianS

Thanks for the references.

I tried both fluent-bit and fluentd approaches - nothing happens.

I mean, test-logger pod is running, daemonsets are created, bu there's no "k8s_container" resources mentioned in Cloud Logs explorer.

Is there a working solution for the latest GKE versions (such as 1.27.* and later)?

Have you enabled WORKLOAD logging on the cluster?  By default, only SYSTEM logging is enabled. 

gcloud container clusters update --logging=SYSTEM,WORKLOAD $CLUSTER_NAME --region $REGION

See https://cloud.google.com/sdk/gcloud/reference/container/clusters/update#--logging

Top Labels in this Space