VOOZH about

URL: https://www.analyticsvidhya.com/blog/2017/05/beginners-guide-to-data-exploration-using-elastic-search-and-kibana/

⇱ Data Exploration Using ElasticSearch and Kibana


India's Most Futuristic AI Conference Is Back – Bigger, Sharper, Bolder

  • d
  • :
  • h
  • :
  • m
  • :
  • s

Reading list

Hands on tutorial to perform Data Exploration using Elastic Search and Kibana (using Python)

Guest Blog Last Updated : 27 Oct, 2024
6 min read

Introduction

Exploratory Data Analysis (EDA) helps us to uncover the underlying structure of data and its dynamics through which we can maximize the insights. EDA is also critical to extract important variables and detect outliers and anomalies. Even though there are many algorithms in Machine Learning, EDA is considered to be one of the most critical part to understand and drive the business.

There are several ways to perform EDA on various platforms like Python (matplotlib, seaborn), R (ggplot2) and there are a lot of good resources on the web such as “Exploratory Data Analysis” by John W. Tukey, “Exploratory Data Analysis with R” by Roger D. Peng and so on..

In this article, I am going to talk about performing EDA using Kibana and Elastic Search.

Table of Contents

  1. Elastic Search
  2. Kibana
  3. Creating dashboards
    • Indexing data
    • Linking Kibana
    • Making visualizations
  4. Search bar

1. Elastic Search (ES)

Elastic Search is an open source, RESTful distributed and scalable search engine. Elastic search is extremely fast in fetching results for simple or complex queries on large amounts of data (Petabytes) because of it’s simple design and distributed nature. It is also much easier to work with than a conventional database constrained by schemas, tables.

Elastic Search provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents.

Installation of Elastic Search

Installation and initialization is quite simple and it is as follows:

  • Download and unzip Elasticsearch
  • Change the directory to Elasticsearch folder
  • Run bin/elasticsearch (or bin\elasticsearch.bat on Windows)

Elasticsearch instance should be running at http://localhost:9200 in your browser if you run with default configuration.

Keep the terminal open where elastic search is running to be able to keep the instance running. you could also use nohup mode to run the instance in the background.

2. Kibana

Kibana is an open source data exploration and visualization tool built on Elastic Search to help you understand data better. It provides visualization capabilities on top of the content indexed on an Elasticsearch cluster. Users can create bar, line and scatter plots, or pie charts and maps on top of large volumes of data.

Installation

Installation and initialization is similar to that of Elasticsearch:

  • Download and unzip Kibana
  • Open config / Kibana.yml in an editor and Set elasticsearch.url to point at your Elasticsearch instance
  • Change the directory to Kibana folder
  • Run bin/Kibana (or bin\Kibana.bat on Windows)

Kibana instance should be running at http://localhost:5601 in your browser if you run with default configuration.

Keep the terminal open where Kibana was run to be able to keep the instance running. you could also use nohup mode to run the instance in the background.

3. Creating Dashboards

There are mainly three steps to create dashboards using ES and Kibana. I will be using Loan prediction practice problem data to create a dashboard. Please register for the problem to be able to download the data. Please check the data dictionary for more information.

Note: In this article I will be using python to read data and insert data into Elasticsearch for creating visualizations through Kibana.

Reading data

import pandas as pd
train_data_path = '../loan_prediction_data/train_u6lujuX_CVtuZ9i.csv'
test_data_path = '../loan_prediction_data/test_Y3wMUE5_7gLdaTN.csv'
train = pd.read_csv(train_data_path); print(train.shape)
test = pd.read_csv(test_data_path); print(test.shape)
(614, 13)
(367, 12)

Python Code:

import pandas as pd

train = pd.read_csv('train.csv')
test = pd.read_csv('test.csv')
print(train.shape)
print(test.shape)

3.1 Indexing data

Elastic Search indexes data into its internal data format and stores them in a basic data structure similar to a JSON object. Please find the below python code to insert data into ES. Please install pyelasticsearch library as shown below for indexing through python.

Note: Please note that the code assumes that the elastic search is run with default configuration.

pip install pyelasticsearch
from time import time
from pyelasticsearch import ElasticSearch

CHUNKSIZE=100

index_name_train = "loan_prediction_train"
doc_type_train = "av-lp_train"

index_name_test = "loan_prediction_test"
doc_type_test = "av-lp_test"
 
def index_data(data_path, chunksize, index_name, doc_type):
 f = open(data_path)
 csvfile = pd.read_csv(f, iterator=True, chunksize=chunksize) 
 es = ElasticSearch('http://localhost:9200/')
 try :
 es.delete_index(index_name)
 except :
 pass
 es.create_index(index_name)
 for i,df in enumerate(csvfile): 
 records=df.where(pd.notnull(df), None).T.to_dict()
 list_records=[records[it] for it in records]
 try :
 es.bulk_index(index_name, doc_type, list_records)
 except :
 print("error!, skiping chunk!")
 pass
index_data(train_data_path, CHUNKSIZE, index_name_train, doc_type_train) # Indexing train data
index_data(test_data_path, CHUNKSIZE, index_name_test, doc_type_test) # Indexing test data
DELETE /loan_prediction_train [status:404 request:0.010s]
DELETE /loan_prediction_test [status:404 request:0.009s]

3.2 Linking Kibana

  • Now point your browser to http://localhost:5601
  • Go to Management. Click on Index Patterns. Click on Add new.
  • Check box if your data indexed contains timestamp. Here, uncheck the box.
  • Enter the same index we used to index the data into ElasticSearch. (Example: loan_prediction_train).
  • Click on create.

Repeat the above 4 steps for loan_prediction_test. Now kibana is linked with train and test data present in elastic search

3.3 Create Visualizations

  • Click on Visualize > Create a Visualization > Select the Visualization type > Select the index (train or test) > Build

Example 1

  • Select Vertical bar chart and select train index for plotting the Loan_status distribution.
  • Select the y-axis as count and x-axis as Loan status
👁 Image
  • Save the visualization.
  • Add a dashboard > Select the index > Add the visualization just saved.

Voila!! Dashboard created.

👁 Image

Example 2

  • Click on visualize > Create a visualization > Select the visualization type > Select the index (train or test) > Build
  • Select Vertical bar chart and select train index for plotting the Married distribution.
  • Select the y-axis as count and x-axis as Married
👁 Image
  • Save the visualization.
  • Repeat the above steps for test index.
  • Open the dashboard already created. Add these visualizations

Example 3

Similarly for Gender distribution. This time we will use pie chart.

  • Click on visualize > Create a visualization > Select the visualization type > Select the index (train or test) > Build
  • Select Pie chart chart and select train index for plotting the Married distribution.
  • Select the slice-size as count and split-slices by Married column
👁 Image
  • Save the visualization.
  • Repeat the above steps for test index.
  • Open the dashboard already created. Add these visualizations

Finally the dashboard with all the visualizations created would look like this!

👁 Image

Beautiful! isn’t it?

Now I leave you here to explore more of elastic search and kibana and create various kind of visualizations

4. Search bar

Search bar allows you to explore data by string search, which helps us in understanding the changes in data with changes in one particular attribute which is not easy to do with visualizations.

Example

  • Go to Discover> Add Loan_Status and Credit_History
  • Using the search bar select only where Credit_History is 0. (Credit_History:0)
  • Now you can observe the changes in Loan_Status column.

Before

👁 Image

After

👁 Image

Insight: Most of the clients that had credit history 0 did not receive Loan (Loan status is N = 92.1%)

That’s all!!

This article was contributed by Supreeth Manyam (@ziron) as part of The Mightiest Pen, DataFest 2017. Supreeth won the competition and also finished second in overall leaderboard of DataFest 2017. Supreeth is a passionate Data Scientist who is keen on bringing insights to business and help it get better by analyzing relevant data using Machine Learning and Artificial Intelligence.

Login to continue reading and enjoy expert-curated content.

Free Courses

Generative AI - A Way of Life

Explore Generative AI for beginners: create text and images, use top AI tools, learn practical skills, and ethics.

Getting Started with Large Language Models

Master Large Language Models (LLMs) with this course, offering clear guidance in NLP and model training made simple.

Building LLM Applications using Prompt Engineering

This free course guides you on building LLM apps, mastering prompt engineering, and developing chatbots with enterprise data.

Improving Real World RAG Systems: Key Challenges & Practical Solutions

Explore practical solutions, advanced retrieval strategies, and agentic RAG systems to improve context, relevance, and accuracy in AI-driven applications.

Microsoft Excel: Formulas & Functions

Master MS Excel for data analysis with key formulas, functions, and LookUp tools in this comprehensive course.

Responses From Readers

Preeti Agarwal

Good One

ankur

not able to import elasticsearch thing...throwing error....from pyelasticsearch import Elasticsearch

ankur

AttributeError: 'Elasticsearch' object has no attribute 'create_index' - getting this error

123 1
Supreeth Manyam

Hi Ankur, Please make sure you have installed pyelasticsearch correctly using `pip install pyelasticsearch` and you are able to import it in python. Following versions were used in this tutorial: pyelasticsearch - 1.2.3 ElasticSearch - 5.3.2 Kibana - 5.3.2 PS: This error could also be caused by the typos in the article as mentioned by Osmar Rodriguez. Now the typos are fixed!

123 456

Flagship Programs

GenAI Pinnacle Program| GenAI Pinnacle Plus Program| AI/ML BlackBelt Program| Agentic AI Pioneer Program

Free Courses

Generative AI| DeepSeek| OpenAI Agent SDK| LLM Applications using Prompt Engineering| DeepSeek from Scratch| Stability.AI| SSM & MAMBA| RAG Systems using LlamaIndex| Building LLMs for Code| Python| Microsoft Excel| Machine Learning| Deep Learning| Mastering Multimodal RAG| Introduction to Transformer Model| Bagging & Boosting| Loan Prediction| Time Series Forecasting| Tableau| Business Analytics| Vibe Coding in Windsurf| Model Deployment using FastAPI| Building Data Analyst AI Agent| Getting started with OpenAI o3-mini| Introduction to Transformers and Attention Mechanisms

Popular Categories

AI Agents| Generative AI| Prompt Engineering| Generative AI Application| News| Technical Guides| AI Tools| Interview Preparation| Research Papers| Success Stories| Quiz| Use Cases| Listicles

Generative AI Tools and Techniques

GANs| VAEs| Transformers| StyleGAN| Pix2Pix| Autoencoders| GPT| BERT| Word2Vec| LSTM| Attention Mechanisms| Diffusion Models| LLMs| SLMs| Encoder Decoder Models| Prompt Engineering| LangChain| LlamaIndex| RAG| Fine-tuning| LangChain AI Agent| Multimodal Models| RNNs| DCGAN| ProGAN| Text-to-Image Models| DDPM| Document Question Answering| Imagen| T5 (Text-to-Text Transfer Transformer)| Seq2seq Models| WaveNet| Attention Is All You Need (Transformer Architecture) | WindSurf| Cursor

Popular GenAI Models

Llama 4| Llama 3.1| GPT 4.5| GPT 4.1| GPT 4o| o3-mini| Sora| DeepSeek R1| DeepSeek V3| Janus Pro| Veo 2| Gemini 2.5 Pro| Gemini 2.0| Gemma 3| Claude Sonnet 3.7| Claude 3.5 Sonnet| Phi 4| Phi 3.5| Mistral Small 3.1| Mistral NeMo| Mistral-7b| Bedrock| Vertex AI| Qwen QwQ 32B| Qwen 2| Qwen 2.5 VL| Qwen Chat| Grok 3

AI Development Frameworks

n8n| LangChain| Agent SDK| A2A by Google| SmolAgents| LangGraph| CrewAI| Agno| LangFlow| AutoGen| LlamaIndex| Swarm| AutoGPT

Data Science Tools and Techniques

Python| R| SQL| Jupyter Notebooks| TensorFlow| Scikit-learn| PyTorch| Tableau| Apache Spark| Matplotlib| Seaborn| Pandas| Hadoop| Docker| Git| Keras| Apache Kafka| AWS| NLP| Random Forest| Computer Vision| Data Visualization| Data Exploration| Big Data| Common Machine Learning Algorithms| Machine Learning| Google Data Science Agent
👁 Av Logo White

Continue your learning for FREE

Forgot your password?
👁 Av Logo White

Enter OTP sent to

Edit

Wrong OTP.

Enter the OTP

Resend OTP

Resend OTP in 45s

👁 Popup Banner
👁 AI Popup Banner