Elastic Search

How to Setup and Configure Kibana With Elasticsearch on Docker for Local Development?

Elasticsearch is an open-source and well-liked analytical and search engine that is usually used to store and analyze various types of data such as unstructured and semi-structural data. The data in Elasticsearch is processed and managed through Rest APIs. To execute these APIs in a more easy format and to manage Elasticsearch through the friendly user interface, users can configure Kibana with Elasticsearch.

In this blog, we will demonstrate the method to set up and configure Kibana with Elasticsearch on Docker.

How to Setup and Configure Kibana With Elasticsearch on Docker for Local Development?

Kibana is a free, open-source, and well-liked visualization tool. It is used to search and analyze Elasticsearch indexes, log analysis, and time series data through visualization tools such as heat maps, pie charts, histograms, and line graphs.

While managing platform-dependent application data in Elasticsearch, users may want to use virtual machines or Docker containers. The Docker containers are an easy way to use Kibana and Elastic search in an isolated virtual environment.

In order to set up and configure Kibana with Elasticsearch on Docker, go through the following steps.

Step 1: Setup and Start Docker
To download Docker on Windows, navigate to its official website and hit the “Download Docker Desktop” button:

Note: For the proper guideline on how to install and setup Docker on Windows, follow over linked post:

Step 2: Create a Network
To create a network that will be used to save Elasticsearch data, utilize the “docker network create <network-name>” command:

docker network create elastic

Note: Creating and embedding a network is not necessary. But it can be used for backup purposes as when the Docker container is removed, it will delete all the essential files and data. To save the data even after the container removal, users can use the created network.

Step 3: Pull the Elasticsearch Image
Next, pull the official Elasticsearch image from Docker official registry through the “docker pull” command: 

docker pull docker.elastic.co/elasticsearch/elasticsearch:8.8.2

Step 4: Run Elasticsearch
In to run the Elasticsearch inside the container, utilize the below command:

docker run --name es01 --net elastic -p 9200:9200 -p 9300:9300 -t docker.elastic.co/elasticsearch/elasticsearch:8.8.2

In the above command:

  • “–name” is specifying the Elasticsearch container name.
  • “–net” is used to embed the external network that is created in the above step.
  • “-p” option is defining the container’s ports.
  • “-t” is used to assign the “TTY-pseudo” terminal to the container:

If the image executes error-free, it will generate the default login credentials such as an “elastic” user and a password. Using these credentials, the user can access Elasticsearch. This will also generate the token as highlighted below. This will be used to configure Kibana with Elasticsearch:

Step 5: Pull Kibana Image
To install and setup Kibana in Docker, pull the Kibana official image from the Docker registry using the given command:

docker pull docker.elastic.co/kibana/kibana:8.8.2

Step 6: Run Kibana
Now, run the Kibana image to create and start executing the Kibana container. By default, Kibana executes on the “5601” port. Therefore, we have used the “-p” option to specify and run the Kibana on the default port:

docker run --name kib-01 --net elastic -p 5601:5601 docker.elastic.co/kibana/kibana:8.8.2

Step 7: Generate Kibana Configuration Token Using Elasticsearch Container
To configure the Kibana with Elasticsearch, the user needs to have the Kibana configuration token that was generated during the execution of Elasticsearch in Step 4. If this token is misplaced, users can regenerate it by using the below command:

docker exec -it es01 /usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s kibana

The above command executes the Elasticsearch token generator command within the Elasticsearch container using the “docker exec” command:

Now, this token can be used to configure the Kibana with Elasticsearch.

Step 8: Configure Kibana With Elasticsearch
Now, to check whether the Kibana is running on the specified port and to configure it with Elasticsearch, navigate to the “localhost:5601” port. Next, to configure the Kibana, paste the above-generated token in the “Enrollment token” field. After that, hit the “Configure Elastic” button:

Upon doing so, Kibana will ask for a verification code that can be found from the terminal console where the user executed the Kibana image to start the container in Step 6:

Here is the verification code to configure Kibana with Elasticsearch. Enter this code on the “Verification required” screen and hit the “Verify” button:

As a result, the Kibana will be configured with Elasticsearch. Now, user can use Elasticsearch with Kibana UI interface:

That’s all about setting up and configuring Kibana with Elasticsearch.

Conclusion

To setup and configure Kibana with Elasticsearch in Docker, first, run the Elasticsearch container by pulling and executing the Elasticsearch official image from Docker registry. After that, pull the official Kibana image and execute it using the “docker run” command. Now, navigate to the “localhost:5601” URL and add the enrollment token that is generated when the Elasticsearch image is executed and hit the “Configure Elastic” button. This article has demonstrated the method to setup and configure the Kibana with Elasticsearch on Docker.

About the author

Rafia Zafar

I am graduated in computer science. I am a junior technical author here and passionate about Programming and learning new technologies. I have worked in JAVA, HTML 5, CSS3, Bootstrap, and PHP.