I want to calculate (sum(my_document_field)/bucket_interval) for all buckets in a date_histogram. Its straightforward to calculate the sum with a sum_bucket aggregation, however I'm having trouble figuring out how to get the interval of the given bucket to calculate the value I'm interested in. The interval specified for the date_histogram may not be constant if 'week' or 'month', etc are used. Is there any way to calculate the interval for the parent bucket?

```
{
"query": {
...
},
"aggregations": {
"by_hour": {
"date_histogram": {
"field": "timestamp",
"interval": "1h",
"extended_bounds": {
"min": "now/d-5h",
"max": "now/d-1h"
}
},
"aggregations": {
"sum_raindrops": {
"sum": {
"field": "raindrops_seen"
}
},
"avg_scripts": {
"bucket_script": {
"buckets_path": {
"var_sum_raindrops": "sum_raindrops"
},
"script": "var_sum_raindrops / (?)"
}
}
}
}
}
}
```