How to view access logs for an application deployed in GKE?

4/3/2019

I have an application deployed in Google Kubernetes Engine. It uses Ingress load balancer and currently there are 2 pods running my application among which API requests are distributed. The application is a Spring Boot application. I can view what API calls made to each pod individually using access logs provided by Spring Boot, but I want to view all the requests at once. I think that's possible because all the requests are first intercepted by load balancer before they get distributed. Is there a way I can do that?

-- Lokesh
google-kubernetes-engine
kubernetes
kubernetes-ingress

2 Answers

4/5/2019

After searching around a bit more I found what I was looking for. To view access logs for application deployed using GKE do the following:

  1. Go to Google Kubernetes Engine and click on Services.
  2. Click on the nginx / ingress controller which your application is using.
  3. Click on the link next to Stackdriver logs.

Here you will find real time logs of API requests to your application.

-- Lokesh
Source: StackOverflow

4/3/2019

Since you are getting the API calls from your application pods, it sounds like putting logs from both pods (assuming they are part of the same app) would help:

kubectl logs -l app=<app name> -n <namespace>
-- cookiedough
Source: StackOverflow