Jenkins And Splunk Integration

Jenkins And Splunk Integration

Jenkins is an open source automation server which enables developers around the world to reliably build, test, and deploy their software.

Just follow the steps below to open a whole new world of insights on your Jenkins master and slave infrastructure and a lot more. You can go through the entire app description on the app page hosted on the Splunkbase.

Step-1:  Download the “Splunk App for Jenkins ”  app.

  https://splunkbase.splunk.com/app/3332/

Step-2:  On your Splunk Indexer navigate to Manage Apps >> Install app from file, upload the add-on you just downloaded and restart Splunk once the installation is complete.

Step-3: Create a Http Event Collector(HEC) token in Splunk. Copy the generated token for further use.

NOTE:  You can keep the index to the default (main, in general) or ‘jenkins’  
or whatever you prefer while setting up the token, as the Splunk app
for Jenkins is capable of filtering the events and redirecting them 
to the correct pre-configured indexes(this app ships with 
four indexes – Jenkins, Jenkins_statistics, Jenkins_console, Jenkins_artifact).

Step-4: Download and install Jenkins on your server.

You can download from here: https://jenkins.io/download/

Select the right package for your platform, here is a guide on how to proceed with the download and installation (tried and tested by us on centos 7).

Step-5: On your Jenkins Master Node, navigate to – Manage Jenkins >> Manage Plugins,

Screenshot (15)

Screenshot (16)

on this page search for “splunk” plugin, click on check box for the splunk plugin and then select your preference of restart for the installation.

Screenshot (1)

Step-6 : Once the plugin is installed go to – Manage Jenkins >> Configure system

Screenshot (4)

Step-7 : Find and fill the Splunk for Jenkins Configuration form.

Screenshot (6)

 Enable – Click on this checkbox to make the configuration for this plugin active.
HTTP Input Host – Mention the host name of the Splunk Indexer where you have installed the Splunk App for Jenkins.
HTTP Input Port – Provide the port on which to communicate with Splunk, by default it’s 8088.
HTTP Input Token – Provide the input token you generated in Step-3.
SSL Enabled – If you want the communication to be encrypted between your Jenkins and Splunk instances (not required, generally, if Jenkins data is not going out of your internal network).
Send all pipeline console logs – Click on this check box if you want all the pipe line logs to be indexed in Splunk.
Jenkins Master Hostname – Provide the Hostname that should appear in your Splunk for the events received from this node.

Step-8 : Click on Test Connection, you should get the below message.

                              “Splunk connection verified

Step-9 : Log into your Splunk Instance and verify the communication, to be double sure.

You will get some “test ping “ events from the Jenkins Master node as shown in the screenshot below.

Screenshot (7)

Step-10 : Let’s try to create a project in Jenkins.

We have created a project named sample as shown below,

P.S – just wanted to explore the integration a little bit more.

Screenshot (17)

Screenshot (19)

Screenshot (11)

Screenshot (12)

We have selected the build periodically option and set the schedule to run every 5 minutes (using CRON expression).

Screenshot (13)

Under the Build option we selected the execute shell option and tried to create a minimal steps shell script,

This script moves the control to /tmp directory and writes/appends the current timestamp/date along with the string “some content” into a file ‘somefile.txt’. It iterates in every 5 minutes as per our CRON expression.

Step-11: Let’s jump to Splunk and find what we got here,

As you can see in the screenshot below, we have got all the build information in the form of events, (sourcetype=text:jenkins)

Screenshot (14)

There you go, you made it, now you can have all the insights that you had always craved for your Jenkins infrastructure.

Additionally, the Splunk app for Jenkins comes with a lot of dashboards and other stuffs to help you out in your voyage.

Navigate to the Splunk app for Jenkins on your Splunk instance, Here is an example screen shot of the project we created, this dashboard is located under the build analysis option.

Screenshot (20)

Happy Splunking!!

You can also know about :  How To Integrate Tableau With Splunk

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.