Analyzing logs in a Kubernetes PODs might not be an overwhelming activity for those who are closely working with Kubernetes container PODs. What if, there are multiple PODs and you need to analyze them all at once? of course some scripting skills can be useful for this, but that can be some time consuming and pre-preparing for the log analysis. I’d like to introduce this great tool called “Stern” for your multiple Container POD analysis, which makes your life more easier.
The Stern can be found in this GitHub page, and follow it for more updates. It has complete build instructions, but not to worry, there are some binary releases available up for grab for instance use. Find these releases and changes in this release page. At the time of writing this article the version is 1.11.0.
Read More: Deploying Harbor Registry And See What’s New With v 1.9
What Are The Benefits With Stern?
If you were to check logs in multiple pods, you’d follow the steps similar to this. Here is a sample log retrieval of my “CoreDNS” pods, which were having two replicas. I might need to check the logs in two different steps with the pod names.
With Stern you can consolidate these two outputs in to a single output, and it provides color codes to easily identify the pods respectively. I used a wildcard character to distinguish the CoreDNS pods as a single entity, eliminating the random characters at the end.
So it is quite easy and reliable method of aggregating the container pod logs for the troubleshooting and analyzing purposes.
How To Install Stern On Linux?
Again, it is available as binary files to direct downloads. I have downloaded the “stern_linux_amd64” file in to my Amazon Linux machine.
Making the downloaded file as an executable would easily run this wonderful tool. There are many options available for the usage and gain the granular control of the tool. Just try that out.