Kibana 4 is a great tool for visualizing data from elasticsearch.  Out of the box Kibana is a node JS application, so requires infrastructure to run it on (as well as the overhead or managing this infrastructure.  It would be great to run Kibana on the PaaS websites offering from Azure, taking away the problems with setup and maintainability, as well as giving you all the great features (scalability, authentication etc) that comes with Azure Websites

Project Setup

1. Download and install Node JS
2, Download and install the node js tools for visual studio
3. Create a new blank Azure Node JS project in visual studio


4. Download and extract the latest version of Kibana
5. Copy the contents of the src folder in the Kibana extract into the root of your website solution, and including in the project (Note you can exclude the node_modules and obj folders).


6. Node JS applications in azure websites use iisnode.  The default web config created by the an Azure Node JS template includes a handler for iisnode, pointing to the file server.js.

IISNode server.js file

This file is the starting point of your Node JS applicication, and will be run by iisnode when the application is accessed in Azure.  In contrast, Kibana has its js file located at /bin/kibana.js.  To simplify things (IIS has issues serving content from the bin folder), we can copy the contents of kibana.js into the server.js starting point for the Azure website that is already in the project.  We now have our project set up, and we just need to make a few further changes so it works seamlessly with Azure Websites.

 Amending Kibana to work with Azure Websites

Kibana.js (now server.js) has a few references to specific modules based on directoty paths, which now change as we have changed the location.  The other thing we need to change is the host and port Kibana listens on.  Node JS applications in Azure Websites have the post and host specified at runtime and injected into the application using the environment variables port and host.  We can update our server.js file to tell kibana to use these variables with:

if (process.env.HOST) {
config.port = process.env.PORT;
if (process.env.HOST) { = process.env.HOST;

The full server.js file with both these updates is below

The last thing we need to do is tell Kibana that we want to use Production mode.  This is done using the environment variable NODE_ENV.  In a standard Kibana deployment this is set in the bat file used to start node.exe. In order to set this in our project, right click on the project in VS and select properties.  You can then add the environment variable in to the project properties

Setting Environment Variables

Configuring Kibana

Kibana is configured using the kibana.yml file. This is updated on build, so grab the built version (/config/kibana.yml) from the downloaded Kibana extract, and overwrite the config/kibana.yml file thats included in the src folder, and is therefore been added to the azure project. You can then setup the kibana.yml file to connect to your elasticsearch cluster by changing the elasticsearch_url property.


Thats it!  We now have a version of Kibana that we can easily deploy into Azure Websites.  Once deployed you have all the great features of kibana with the infrastructure of azure websites.


Further amendments

1. If you have your elastic search instance restricted by IP, you will need to get an IP for your azure websites Kibana instance.  This can be easily done by adding an SSL cert.

2. You can easily add AD authentication to your Kibana instance by using the built in features in Azure websites.

Leave a Reply

Your email address will not be published. Required fields are marked *