Thursday, September 24, 2020

Monitor Application Logs - Kubernetes

 A user - 'USER5' - has expressed concerns accessing the application. Identify the cause of the issue. Inspect the logs of the POD

master $ kubectl get pods

NAME       READY   STATUS              RESTARTS   AGE

webapp-1   0/1     ContainerCreating   0          12s

master $ kubectl get pods

NAME       READY   STATUS    RESTARTS   AGE

webapp-1   1/1     Running   0          93s

master $ kubectl logs -f webapp-1

[2020-09-25 02:59:05,519] INFO in event-simulator: USER4 logged out

[2020-09-25 02:59:06,520] INFO in event-simulator: USER2 is viewing page2

[2020-09-25 02:59:07,522] INFO in event-simulator: USER4 is viewing page1

[2020-09-25 02:59:08,522] INFO in event-simulator: USER4 logged in

[2020-09-25 02:59:09,524] INFO in event-simulator: USER1 logged in

[2020-09-25 02:59:10,525] WARNING in event-simulator: USER5 Failed to Login as the account is locked due to MANY FAILEDATTEMPTS.

The logs clearly indicate the user was logged out due to many failed attempts.

A user is reporting issues while trying to purchase an item. Identify the user and the cause of the issue.

Inspect the logs of the webapp in the POD

Let's first try the same thing we tried above i.e kubectl logs -f <podName> 

master $ kubectl logs -f webapp-2

error: a container name must be specified for pod webapp-2, choose one of: [simple-webapp db]

Doing so gave us error because it has multiple images and we need to specify the name of the container.

First run kubectl describe <podName> and look for containers created and then subsequently try looking logs for those container :

kubectl logs -f <podName> <containerName>


No comments:

Post a Comment