Sivvie Lim
Sivvie Lim

Reputation: 1286

How to check logs in MongoDB that hosted using Kubernetes?

I found out that my database that was hosted on Kubernetes constantly getting removed all the data in a collection after some time. I want to make sure it isn't some sort of deployment or config error so I would like to check the logs of MongoDB itself.

I tried kubectl logs <mongodb-pod-name> but it only logs the connection and disconnection to the mongodb pod. Would like to access to mongodb.log file to check if the data is removed automatically or someone had executed a command to remove it.

The mongo db is hosted on Amazon EKS.

Is it possible or there is any other way that I can investigate this issue? Appreciate the help!

Upvotes: 0

Views: 2050

Answers (1)

Thanh Nguyen Van
Thanh Nguyen Van

Reputation: 11842

You can:

kubectl describe pod <mongodb-pod-name>

Then, you can access the container :

kubectl exec --stdin --tty <mongodb-pod-name>  -- /bin/bash

or:

  kubectl exec --stdin --tty <mongodb-pod-name>  -- sh

And see logs inside the container

Upvotes: 3

Related Questions