# Aggregate on timstamp part

**URL:** https://discuss.elastic.co/t/aggregate-on-timstamp-part/63073
**Category:** Kibana
**Created:** [October 14, 2016, 6:56pm UTC](https://discuss.elastic.co/t/aggregate-on-timstamp-part/63073 "2016-10-14T18:56:29Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Bruno\_Lavoie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bruno_lavoie/32/8408_2.png) [@Bruno\_Lavoie](https://discuss.elastic.co/u/Bruno_Lavoie)
#### Post date: [October 14, 2016, 6:56pm UTC](https://discuss.elastic.co/t/aggregate-on-timstamp-part/63073/1 "2016-10-14T18:56:29Z")

</div>

Hello,

I would like to make graphs on a specific part of @timestamp field.  
Say, we want an average per hour over a certain period of time.

Is it possible to do that easily in Kibana?  
Do we need a script field? If yes, how?

Is it necessary to preprocess this date field splitting in logstash to make it possible?

Thanks  
Bruno Lavoie

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [October 15, 2016, 9:01pm UTC](https://discuss.elastic.co/t/aggregate-on-timstamp-part/63073/2 "2016-10-15T21:01:37Z")

</div>

Just set the time buckets to hourly in the agg. But that wont work over (eg) years of data as the granularity is too small.

---

<div class="post-metadata">

### Author: ![Bruno\_Lavoie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bruno_lavoie/32/8408_2.png) [@Bruno\_Lavoie](https://discuss.elastic.co/u/Bruno_Lavoie)
#### Post date: [October 17, 2016, 2:41pm UTC](https://discuss.elastic.co/t/aggregate-on-timstamp-part/63073/3 "2016-10-17T14:41:27Z")

</div>

Oh, maybe I wasnt clear enough...

I want a bucket/aggregation by time part (day of week, hour).  
So, if I select last year with an agregation on hour part of @timestamp, I will have 24 buckets (one for each hour).

The only way that I've found is to add a scripted field in kibana:

`doc['@timestamp'].getHourOfDay()`

But I have questions regarding performance of this and where is it executed: in kibana or ES?  
And, big drawback of this solution is that it's not timezone aware: extracted values are in UTC. Any way to convert it back to the client TZ?

Thansk  
Bruno Lavoie

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [October 17, 2016, 10:40pm UTC](https://discuss.elastic.co/t/aggregate-on-timstamp-part/63073/4 "2016-10-17T22:40:35Z")

</div>

So you want a bucket of 0000-0100 for all days in the year?

---

<div class="post-metadata">

### Author: ![Bruno\_Lavoie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bruno_lavoie/32/8408_2.png) [@Bruno\_Lavoie](https://discuss.elastic.co/u/Bruno_Lavoie)
#### Post date: [October 18, 2016, 12:22pm UTC](https://discuss.elastic.co/t/aggregate-on-timstamp-part/63073/5 "2016-10-18T12:22:13Z")

</div>

> [@warkolm](#):
>
> -0100 for all days in the year?

hum the buckets would be:

- 00h00
- 01h00
- ...
- 23h00

this can be for the year or last month or whatever the user select in time range in Kibana.

Thanks

---

<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:36pm UTC](https://discuss.elastic.co/t/aggregate-on-timstamp-part/63073/6 "2017-07-06T13:36:21Z")

</div>


