# How to print popular hour diagram in Kibana

**URL:** https://discuss.elastic.co/t/how-to-print-popular-hour-diagram-in-kibana/64277
**Category:** Kibana
**Created:** [October 28, 2016, 12:29pm UTC](https://discuss.elastic.co/t/how-to-print-popular-hour-diagram-in-kibana/64277 "2016-10-28T12:29:22Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![kay\_kay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kay_kay/32/1470_2.png) [@kay\_kay](https://discuss.elastic.co/u/kay_kay)
#### Post date: [October 28, 2016, 12:29pm UTC](https://discuss.elastic.co/t/how-to-print-popular-hour-diagram-in-kibana/64277/1 "2016-10-28T12:29:22Z")

</div>

I'd like to print a diagram which will show the most popular/unpopular visit time over working days.

I.e. from monday till friday only for last months it should print a diagram with Y - amount of logs, X - 00-01h 01-02h 02-03h 03-04h 04-05h 05-06h 06-07h ... 23-24h

Is it possible to do that in Kibana?

---

<div class="post-metadata">

### Author: ![kay\_kay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kay_kay/32/1470_2.png) [@kay\_kay](https://discuss.elastic.co/u/kay_kay)
#### Post date: [October 28, 2016, 1:20pm UTC](https://discuss.elastic.co/t/how-to-print-popular-hour-diagram-in-kibana/64277/2 "2016-10-28T13:20:31Z")

</div>

Looks like I need a hourly heatmap, but it requires old data reindex. Can someone suggest how to achieve that?

---

<div class="post-metadata">

### Author: ![kay\_kay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kay_kay/32/1470_2.png) [@kay\_kay](https://discuss.elastic.co/u/kay_kay)
#### Post date: [October 28, 2016, 4:10pm UTC](https://discuss.elastic.co/t/how-to-print-popular-hour-diagram-in-kibana/64277/3 "2016-10-28T16:10:48Z")

</div>

Looks like my question related to [Day of Week](https://discuss.elastic.co/t/day-of-week/33295/4)

---

<div class="post-metadata">

### Author: ![kay\_kay](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kay_kay/32/1470_2.png) [@kay\_kay](https://discuss.elastic.co/u/kay_kay)
#### Post date: [October 31, 2016, 2:25pm UTC](https://discuss.elastic.co/t/how-to-print-popular-hour-diagram-in-kibana/64277/4 "2016-10-31T14:25:25Z")

</div>

It is not a problem when you use Elasticsearch 5.x and Kibana 5.x.  
But for old ES 2.4.x and Kibana 4.6.1 it's kinda challenge, but I found the solution:

Alter Elasticsearch security config:

```
script:
  engine:
    groovy:
      inline:
        search: true # you'll be able to get value of this field in search results
        aggs: true # you'll be able to use this field in search aggregation in histogram

```

Create two numeric scripted fields in Kibana:

- **time.hourOfDay** -\> **doc['time'].getHourOfDay()** - it is a simple Lucene expression
- **time.dayOfWeek** -\> **doc['time'].date.dayOfWeek** - it is a groovy script which won't work without a hack below:

Then in Chrome open the developer tools -\> network and find the query which applies these rules and using right click choose **Copy as cURL**

Alter this command and set **groovy** instead of **expression** inside the **lang** field for the **time.dayOfWeek** field and run the command.

Then try to discover the logs and you should find **time.dayOfWeek** and **time.hourOfDay** in log fields.

Now you can create a heatmap ([https://github.com/stormpython/heatmap](https://github.com/stormpython/heatmap)) with the properties below:

- Columns: time.dayOfWeek
- Rows: time.hourOfDay

And now you see that people don't work on Friday evenings 🙂 :

 ![](https://us1.discourse-cdn.com/elastic/original/2X/2/2340505526471a568c69568de4eaea834a4285d9.png)

---

<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: [July 6, 2017, 1:35pm UTC](https://discuss.elastic.co/t/how-to-print-popular-hour-diagram-in-kibana/64277/5 "2017-07-06T13:35:03Z")

</div>


