# Date Histogram in Kibana

**URL:** <https://discuss.elastic.co/t/date-histogram-in-kibana/159800>\
**Category:** Kibana\
**Created:** [December 6, 2018, 8:41pm UTC](https://discuss.elastic.co/t/date-histogram-in-kibana/159800 "2018-12-06T20:41:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![malsioufi](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@malsioufi](https://discuss.elastic.co/u/malsioufi)\
**Post date:** [December 6, 2018, 8:41pm UTC](https://discuss.elastic.co/t/date-histogram-in-kibana/159800/1 "2018-12-06T20:41:13Z")

</div>

Hi,  
I have data indexed in Elastisearch. The data is sensors readings per hour for multiple stations and it has the following shape  
`{ "type": "Temperature", "time": "2012-01-01T01:00:00", "station": "stationX", "value": -9.24249 }`

I have the data of around 5 years. What I want to do is to build a visualization where I can have the average of the values on the Y-axis and the time on the X-axis, I managed to build this visualization easily using Line Visualization, Y-axis as Average of field value, and X-axis as Date Histogram. What I want to do is to modify this visualization, so I can show the data of each year in a separate series, and where X-axis are the month and days like it is shown in the image below:

 ![Example](https://us1.discourse-cdn.com/elastic/original/3X/2/b/2be1f762ea6930c8b04e1d8e6f7fa4036b91fa2a.png)

---

<div class="post-metadata">

**Author:** ![bryan\_stuhlsatz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bryan_stuhlsatz/32/49123_2.png) [@bryan\_stuhlsatz](https://discuss.elastic.co/u/bryan_stuhlsatz)\
**Post date:** [December 6, 2018, 9:24pm UTC](https://discuss.elastic.co/t/date-histogram-in-kibana/159800/2 "2018-12-06T21:24:37Z")

</div>

You could easily do this if you had a field in your data that was called month. Your first bucket would be a histogram using that field. Then you would split the series using a date range filter specifying your years. Lastly, your kibana index pattern can not be time series based because your x-axis you want is based on months and not the whole span of 5 years of time. I would re-index the data, and you could do a painless script to accomplish creating the field.

---

<div class="post-metadata">

**Author:** ![bryan\_stuhlsatz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bryan_stuhlsatz/32/49123_2.png) [@bryan\_stuhlsatz](https://discuss.elastic.co/u/bryan_stuhlsatz)\
**Post date:** [December 6, 2018, 10:10pm UTC](https://discuss.elastic.co/t/date-histogram-in-kibana/159800/3 "2018-12-06T22:10:16Z")

</div>

On splitting the series, i mentioned using a date range filter. That works if you want like a rolling week, month, etc. You would use date histogram to split the series if you wanted your series to be weekly, yearly, etc.

---

<div class="post-metadata">

**Author:** ![malsioufi](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@malsioufi](https://discuss.elastic.co/u/malsioufi)\
**Post date:** [December 6, 2018, 10:21pm UTC](https://discuss.elastic.co/t/date-histogram-in-kibana/159800/4 "2018-12-06T22:21:19Z")

</div>

Thanks for your answer!  
I am aware of that solution but this is not what I really interested in doing, because then I will have to do it for every time level (Year, Month, Day, Hour, Minute). What I am more interested in is to find a way in Kibana to do so instead of having a new field in my data.  
I think the solution somewhere around splitting the series again using date ranges but I am not very sure about how to do this

---

<div class="post-metadata">

**Author:** ![bryan\_stuhlsatz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bryan_stuhlsatz/32/49123_2.png) [@bryan\_stuhlsatz](https://discuss.elastic.co/u/bryan_stuhlsatz)\
**Post date:** [December 6, 2018, 11:07pm UTC](https://discuss.elastic.co/t/date-histogram-in-kibana/159800/5 "2018-12-06T23:07:53Z")

</div>

If you don't re-index, then the only thing i can think of is you can create a scripted field to do this, or in your visualization write an inline painless script to get the month that is in your date field. I believe that should be doable as well.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 3, 2019, 11:07pm UTC](https://discuss.elastic.co/t/date-histogram-in-kibana/159800/6 "2019-01-03T23:07:53Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
