Date Histogram Aggregation with predefined number of buckets possible?

I would like to get an aggregation to build a histogram off of a date field, but I would like to predefine the EXACT number of buckets to use. So for example if I have data indexed for June 1st and I ask for 10 buckets I would get something like:
2021-06-01_00-00-00-000 : 188,
2021-06-01_02-24-00-000 : 253,
2021-06-01_04-48-00-000 : 77,
2021-06-01_07-12-00-000 : 123,
2021-06-01_09-36-00-000 : 98,
2021-06-01_12-00-00-000 : 87,
2021-06-01_14-24-00-000 : 122,
2021-06-01_16-48-00-000 : 116,
2021-06-01_19-12-00-000 : 142,
2021-06-01_21-36-00-000 : 121

I know that the Auto Date Histogram is close to this however it doesn't guarantee exactly 10 buckets, it just tries to get as close as it can without going over. I know my example above is simple and most often my bucket times will be much less round of numbers than above.

Worst case I think I can get the first query result and last query result, then build a custom range aggregation, would be nice if there was something in the API to do this, so figured I would throw it out there for feedback.

Thanks, Any help is greatly appreciated!

How about the auto interval date histogram aggregation?

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