Reputation: 33
Have few developer logs in kubernetes pods, what is the best method to get the logs for the developers to see it.
Any specific tools that we can use?
I have the option of graylog, but not sure if that can be customized to get the developer logs into it.
Upvotes: 3
Views: 2307
Reputation: 22198
If you want to see the application logs - from the development side you just need to print logs to the STDOUT
and STDERR
streams.
The container runtime (I guess Docker in your case) will redirect those streams
to /var/log/containers
.
(So if you would ssh into the Node you can run docker logs <container-id>
and you will see all the relevant logs).
Kuberentes provides an easier way to access it by kubectl logs <pod-name>
like @Wytrzymały_Wiktor described.
(Notice that the logs are being rotated automatically every 10MB so the kubectl logs
command will show the log entry from the last rotation only).
If you want to send the logs to a central logging system like (ELK, Splunk, Graylog etc') you will have to forward the logs from your cluster by running log forwarders inside your cluster.
This can be done for example by running a daemonset that manage a pod on each node that will access the logs path (/var/log/containers
) by a hostPath
volume and will forward the logs to the remote endpoint. See example here.
Upvotes: 0
Reputation: 13898
The most basic method would be to simply use kubectl logs
command:
Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.
Here you can find more details regarding the command and it's flags alongside some useful examples.
Also, you may want to use:
Both should do the trick in your case.
Please let me know if that is what you had on mind and if my answer was helpful.
Upvotes: 3