If you are reading some technical blogs, maybe about search or data analysis, chances are big you have read about Kibana. You have seen stories about how easy it is to use. Most of the blogging effort deals with getting data into kibana using logstash for instance. Maybe some of you have installed Kibana and are using it in combination with logstash. But what if you want to analyze other data. With the most recent release M4, Kibana is better than ever in analyzing other sort of data. In this blog I am going to show you how to create your own dashboard in Kibana. In order to do something useful with Kibana we have to have data. Peter Meijer had a very nice idea to index metadata from all of your images to learn about the type of photo’s that you take. I decided to put this in practice. I used Node.js and the exiftool to obtain metadata from images and store it in elasticsearch.
Goal of the project #
Using this project you can scan a directory structure for jpg files. Using the exiftool (see installation instructions later on) you can abstract meta-data from you images and insert them into elasticsearch. Then we want to get information about aperture, focal length, iso, exposure from our photo’s using Kibana.
Installation #
You need to install the following libraries. Instructions for installation are on the different websites.
- Exiftool : http://www.sno.phy.queensu.ca/~phil/exiftool/ (tested with version 9.41)
- Elasticsearch : http://www.elasticsearch.org/download (tested with version 0.09.7)
- Kibana : http://www.elasticsearch.org/overview/kibana/installation/ (tested with version 3 Milestone 4)
- Node.js : http://nodejs.org (tested with version 0.10.22)
Setup #
First we are going to check if your environment is setup right.
- Elasticsearch : Point your browser to http://localhost:9200, you should see a json object with some information about your cluster.
- Exiftool : This must be available on your path, type exiftool, you should see the man page of exiftool now.
- Node.js : Check if node and npm are on your path, node -v and npm -v should present you the version that you have installed.
- Kibana : Kibana should be pointed to your elasticsearch server. For now I assume you have everything running on your local machine. You can copy all files from kibana to your webserver. I personally like to host it as an elasticsearch plugin. To do this, create a folder kibana/_site in the plugins folder of elasticsearch and copy all the kibana files here. Then point your browser to http://localhost:9200/_plugin/kibana and you should see the interface. Usually with a warning that it cannot find an index.
Now we can obtain the sources and run the program. Clone the github repository. Step into the folder and download the required libraries using npm.
# git clone git@github.com:jettro/nodejs-photo-indexer.git
# cd nodejs-photo-indexer
# npm installAfter npm install you should have the folder node_modules with the modules exif2 and walk. The exif2 library is used as an interface to the exiftool library, walk is used to traverse a directory structure. These dependencies are configured in the file package.json. Next step is to initialize the elasticsearch index. We have a node.js command for that. This command deletes the index and recreates the index with the right mapping.
# node initindexNow you can check the mapping for the created index, browse to the following url (or use curl). This should show you part of the content from the settings.json file. http://localhost:9200/myimages/local/_mapping?pretty
{
"local" : {
"_all" : {
"enabled" : false
},
"properties" : {
"aperture" : {
"type" : "string"
},
"camera" : {
"type" : "string",
"index" : "not_analyzed",
"omit_norms" : true,
"index_options" : "docs"
},
"compensation" : {
"type" : "string"
},
"createDate" : {
"type" : "date",
"format" : "yyyy:MM:dd HH:mm:ss"
},
"exposure" : {
"type" : "string",
"index" : "not_analyzed",
"omit_norms" : true,
"index_options" : "docs"
},
"focalLength" : {
"type" : "string",
"index" : "not_analyzed",
"omit_norms" : true,
"index_options" : "docs"
},
"iso" : {
"type" : "integer"
},
"lens" : {
"type" : "string",
"index" : "not_analyzed",
"omit_norms" : true,
"index_options" : "docs"
},
"name" : {
"type" : "string",
"index" : "not_analyzed",
"omit_norms" : true,
"index_options" : "docs"
},
"shutter" : {
"type" : "string",
"index" : "not_analyzed",
"omit_norms" : true,
"index_options" : "docs"
}
}
}
}As you can see, there are a lot of fields that are not analyzed. This is important since we do not want texts like Canon eos 7d to be analyzed. We want to have it as one term. The same is valid for lens names, exposure and shutter speed. This is it, now is the moment you can start importing images. You can run the app and provide the initial folder to start scanning.
# node app /path/to/your/PicturesWhile importing, you should see the log showing which pictures it is indexing and which files it skips. When you have your images in elasticsearch it is time to open kibana in a browser and load the dashboard we have created.
Kibana #
We start of with the clean dashboard variant. So in the initial screen choose the Blank Dashboard link. Using this dashboard I can already explain a few of the features. 
- Make sure you have the filters toggled on, this way you can see the filters that we later create by clicking on terms.
- The action buttons from left to right: homescreen, loading saved dashboards, saving the dashboard, sharing the dashboard and configuring the dashboard.
- Kibana is structured in rows and panels. You can determine the height of the row yourself.
Now we first open the dashboard settings using the gear wheel in the top right of the screen. We can give the dashboard a name, style it, select an index and create and order rows. More settings are available but I do not need those for the demo. Let us give the dashboard a name, add a row and make this row 300px of height. We are going to use this row to show the basic image data: Aperture, exposure and focal length. Than we create a second row to show more information about iso values. We leave the height to 150px. Than we have a third row where we show the camera’s and the lenses. In the final row we add a big table where you can browse all data in a table where you can select the fields you want to show. The following image shows the end result of the configuration of the rows. 






Concluding #
I hope this inspires you to start playing with Kibana. I think this is a very nice tool that can be used to do all sorts of data analysis. The only way to learn is to create an index you know and understand and create panels yourself. If you see strange or unexpected results take a good look at the analysis of your data. Elasticsearch comes with great power, but with great power you can make big mistakes. If you want to play around with my index, you can download the index together with the dashboard at this url: http://info.trifork.nl/rs/jteam/images/blog-kibana-example-index.zip If you want to learn more about logstash and kibana have a look at another blogpost of mine: Oh no, more logs …