Skip to main content

@Jenkinsci analytics with @Elasticsearch and #Kibana

I have been doing a lot of work with presenting Jenkins data in dashboards. Jenkins by default does not come with a built-in database. All the data gets stored in the filesystem. However, Jenkins has a REST API that allows us to read data as json. I searched around the Googlesphere to see if anyone had figured out how to capitalize on this REST API for performing analytics and found almost nothing directly related to this.

I was searching for open to public Jenkins instances to see how other people use Jenkins. I came across Elasticsearch's Jenkins site and I was pleasantly surprised. Elasticsearch is a json document storage application. There is a Jenkins plug-in that directly inputs data to Elasticsearch. 

I implemented this proof of concept to perform Jenkins analytics with Elasticsearch as the document store and Kibana as the analytics engine. I automated the installation part using Docker. There are better ways to automate this. The steps given below do not require any knowledge of Docker. 

Pre-requisites:

Vagrant
Oracle VirtualBox
Docker client installed on a running Ubuntu Vagrant box

Step 1: Create the docker containers

Execute the following docker commands to create the Docker containers needed for each of the apps.

#Create Elasticsearch container
docker run --name elasticsearch --hostname elasticsearch -p 9200:9200 -p 9300:9300 -d elasticsearch

#Create Jenkins container
docker run -p 8080:8080 -p 50000:50000 -v $HOME/jenkins_home:/var/jenkins_home --link elasticsearch:es --name jenkins -d jenkins

#Create Kibana container
docker run -e ELASTICSEARCH_URL=http://elasticsearch:9200 -p 5601:5601 --link elasticsearch:es --name kibana -d kibana


Step 2: Port forwarding from VirtualBox to host

Expose the following ports between the host computer and the virtual machine. Optionally, you may choose to add this to the Vagrantfile so that the port forwarding is automatically set whenever the Vagrantbox is started.

8080:8080

9200:9200

5601:5601


Step 3: Install the Jenkins Logstash plug-in

Click on Manage Jenkins and Manage Plug-ins



Click on 'Available' and Filter for 'Logstash'. Checkbox and click install without restart.

Step 4: Configure Jenkins to push data to Elasticsearch

Open http://localhost:8080/configure from a browser on the host computer. Look for the 'Logstash Plugin' section and fill out the following details.

Indexer type: ELASTICSEARCH
Host name: http://localhost
Port: 9200
Username: 
Password: 
Key: /logstash/type

Step 5: Create a Jenkins job and configure

Create a new jenkins job.


Check 'Send the console log to Logstash'.


Add a build step 'Execute shell'.


Step 6: Run Jenkins job

Run the job and see the console log.





Step 7: Verify data is getting to Elasticsearch

Open http://localhost:9200/logstash/_search?pretty in a browser and search for the jobname in the json.

Step 8: Get started with Kibana

I am still trying to figure out Kibana. Check out the visualize section and try to create a graph. I'll post that on another blogpost.

Open 'http://localhost:5601' in a browser and try it out.



Popular posts from this blog

A @trello board to get kids excited

My 8 year old just started his summer break. He did so well in school and I am proud of him. He skipped second grade, got into the gold honor roll in every quarter and got a medal for doing that. Last night, I promised to install a new app for him on his iPad mini. I installed Trello and created a board for him while he watched. I showed him how to create cards, add labels to them and move them from To Do, to Doing to Done. I had him create some cards and label them. He could not stop creating cards. I could not convince him to go to bed after that. He created cards for everything he wants to do in the summer and he is not done with creating cards. He even created a card to email a screenshot of his Trello board to his teacher.

Later last night, he was still awake in bed when I checked on him. He told me that he wanted to add three more labels - Math, Science and One-on-One. He wanted a label titled 'One-on-one' for tasks that he wants to do with me and he wants one-on-one att…

A @trello board to get kids excited - continued

This is a continuation of the previous post titled - A trello board to get kids excited. At the time of writing this post, the previous post had 198 page views. I wish people commented. I did get some positive feedback on Twitter. The Trello twitter account re-tweeted my tweet and also sent out a second tweet advertising the page. Thank you very much. I hope a lot of parents and kids benefited and had fun as a result.

Trello people: Idea - How about a 'Trello Kiddo'? Perhaps you could offer that to schools that give iPads for each kid to take home with them. Get them when they are young.

When a kid does something religiously, regularly and feels great about it and can't wait to tell everyone about it, you know you've done well as a parent. We realized that we needed a separate column to keep track of 'Special accomplishments'. Positive reinforcement that you can see with your eyes!

Some parents feel like they haven't done enough for their kids, particularly…

#Git starter cheat sheet

Initialize a local repo Run the following command in the folder where you would like to initialize a git repo.
git init
Get status It is a good practice to frequently run check on status during development. The following command points out the changes between the previous commit and current state of the folder.
git status
Add content To add an untracked file named ‘text.txt’ to the staging area, execute the following command.
git add text.txt
Syntax: git add <filename>
Commit changes To commit changes made to the folder, execute the following command. The message will be used as a commit message to associate this check-in with the message.
git commit –m “Add text.txt to the code base.”
Syntax: git commit –m “<Commit message>”
Add using wild card To add multiple files using a wild card character, execute the following command.
git add ‘*.txt’
Syntax: git add ‘<wildcard_character+string>’
Check history Review commit history using the following command.
git log
Add Remote re…