Date Histogram when only have start and end dates (or duration)?

I'd like to plot the number of car trips ongoing on a particular day, every day for the last week. I know the start time and end time of the trips - the trips can last less than a day, or more than a day. Ultimately, I will allow the user to set the interval size (i.e. from every day, to every two days, etc.) and the date range (i.e. from the last week, to the last two weeks, etc.).

It looks like date histogram aggregation might help, but it appears to, in addition to the interval size, take a single date field from which to aggregate into buckets. In my case, as I only have the start and end times, I'd need some way for the histogram aggregator to calculate, based on start and end times, whether a given trip fits into a given interval bucket. Also, a given trip would potentially need to be counted in multiple buckets.

What's the best way to do this?

You might find the following link helpful for this. It is a very similar use-case:

Specifically this post in the topic, but I recommend reading the whole topic to get context: Display concurrency in data on Kibana - #3 by colings86

1 Like

Beautiful! Thank you very much!