Hello Readers! In this blog, we are going to see how we can analyze Jenkins build logs using the ELK stack. As Jenkins is known for its automation and we have a number of its builds logs. Here analysis of Jenkins build logs plays a huge role. So, I will explain and show you how we can monitor and analyze Jenkins build logs in our kibana dashboard.
Prerequisites:
- Jenkins should be up and running. Follow the following blog for the setup of Jenkins: https://blog.knoldus.com/jenkins-installation-and-creation-of-freestyle-project/
- Set up the ELK stack. Follow the blog for installation:
https://phoenixnap.com/kb/install-elasticsearch-ubuntu
https://www.elastic.co/guide/en/kibana/7.17/deb.html
My elastic search and kibana are in a running state as you can see below:
Let’s start!
Step 1: Install the logstash plugin in Jenkins. Go to Manage Jenkins>Manage Plugins>Available
It is now installed for me.
Step 2: Create a Jenkins job. For me, it will be a freestyle project.
Now we will configure this Jenkins job. Select send console log to Logstash.
Inside Post-build actions, Select send console log in Logstash.
Add your GitHub project to Jenkins which you want to build.
Save the configuration and apply it.
Step 3: Go to Manage Jenkins > Global Tool Configuration.
Select Logstash plugin.
Inside this fill in the details of Elasticsearch. Inside elasticsearch URI fill in http://localhost:9200/yourindex_name/yourindex_type. My index name will be Jenkinsdata which I will create in the next step. Fill in as per your wish.
Save and apply it.
Step 4: Create an index in elasticsearch which we have mentioned above step. All the Jenkins job build logs will be sent to this particular index only. Create it by sending a request using the PUT method.
My index is created successfully.
Step 5: Create an index pattern in kibana. Move to Kibana > Management > Index pattern. Select your index and create an index pattern. We can analyze our logs using this pattern in kibana.
Step 6: Now we are all set. Just Build that Jenkins job and finally move to Kibana > Discover. You can see your build logs details thereby selecting the index pattern.
Apply the filters as per your requirement. We have sent all our Jenkins build logs to elastic search and visualized those logs using Kibana.
We are all done now!!!
Conclusion:
Thank you for sticking to the end with me. In this blog, we have seen how we can analyze Jenkins build logs using the ELK stack. If you like this blog, please share my blog and show your appreciation by giving thumbs-ups, and don’t forget to give me suggestions on how I can improve my future blogs that can suit your needs.
HAPPY LEARNING!