Creating Box Plot in Kibana using Vega Part – 1

By | December 8, 2020

Creating Box Plot in Kibana using Vega is what this tutorial all about. To keep it simple I will use hard coded data. However in the second part of this tutorial the data will come via aggregation from elasticsearch and will be plotted.


  1. Box plots are very useful and manufacturing engineers especially love them.
  2. Kibana at the time of writing does not support boxplot visualization. Yikes!
  3. Good news: Box plots are supported in Vega-Lite 4.0. And Kibana allows us to use Vega to make visualizations. Lets do it.
  4. Bad news: Kibana 7.x supports only Vega-Lite 2.6.0. Facepalm.

However here is the big thing. Boxplot aggregation is supported in Elasticsearch 7.x. This opens an avenue to actually plot the results of this aggregation using plain simple Vega.

Idea itself is simple. Do the aggregation in Elasticsearch itself. The values it returns are then used in creating Box Plot in Kibana using Vega.

Life Pro Tip: It is always recommended to do aggregations in Elasticsearch as much as possible. Extracting the raw values out and running Vega on it is not going to scale. It is doomed to end in grief.


Open kibana and go into visualizations. Choose Vega visualization. Just paste the code snippet given below.

Click on Update button. And you will see a nice box plot.
Box plot in kibana using Vega

I have added a nice touch. It supports hover text!!
Box plot in kibana using Vega
This is very important to a manufacturing engineer. It enables him to see the actual values if needed without leaving the plot.

So what is happening in this code?
I will not go into nitty gritty of the code. Honestly if you are well versed in Vega you won’t be here. On the other hand if you are not comfortable with Vega then you are out of luck. I won’t be explaining it. It will make this tutorial way too long and complicated.

However here are some points. The data I want to plot is named boxdata and is in the same format as the elasticsearch aggregation returns. Well almost. Ask in comments if you need clarifications on some section of code.

Part two of this tutorial will be all about linking the data in Elasticsearch to this Box plot. Stay tuned.

box plot in kibana using vega

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.