# How to retrieve the interval value in an Aggregation script

**URL:** <https://discuss.elastic.co/t/how-to-retrieve-the-interval-value-in-an-aggregation-script/56959>\
**Category:** Elasticsearch\
**Created:** [August 2, 2016, 6:40am UTC](https://discuss.elastic.co/t/how-to-retrieve-the-interval-value-in-an-aggregation-script/56959 "2016-08-02T06:40:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![richard.rothwell](https://avatars.discourse-cdn.com/v4/letter/r/848f3c/32.png) [@richard.rothwell](https://discuss.elastic.co/u/richard.rothwell)\
**Post date:** [August 2, 2016, 6:40am UTC](https://discuss.elastic.co/t/how-to-retrieve-the-interval-value-in-an-aggregation-script/56959/1 "2016-08-02T06:40:55Z")

</div>

Hi,

I am trying to convert a sum of bytes value per bucket obtained from time series data into a bytes per second value for display in Kibana. A date histogram is being used to perform the aggregation.

This can be calculated for a fixed bucket interval of 60 seconds by a script like so:

{script: \_value \* 8 /60}

But Kibana adapts the bucket size (or interval) depending on the time range of the chart. So it would be nice if the Groovy script had access to some kind of context value it could navigate the context, find the interval value set by Kibana for the aggregation and then use this value in the calculation.

Is this possible?

Regards

---

<div class="post-metadata">

**Author:** ![aurelien.marty](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@aurelien.marty](https://discuss.elastic.co/u/aurelien.marty)\
**Post date:** [October 7, 2016, 8:18am UTC](https://discuss.elastic.co/t/how-to-retrieve-the-interval-value-in-an-aggregation-script/56959/2 "2016-10-07T08:18:56Z")

</div>

Hi,

I'm also interested by a solution.

Regards,  
Aurélien

---

<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 5, 2017, 10:14pm UTC](https://discuss.elastic.co/t/how-to-retrieve-the-interval-value-in-an-aggregation-script/56959/3 "2017-07-05T22:14:07Z")

</div>


