Concurrent running jobs histogram query

Hi all,

I have a data source a few million jobs. As attributes they have start_time, end_time and id.
Jobs have random run times...some are still running.

So a short example could be this:

[
    {id: 1, start_time: "2019-01-01 00:00:00" , end_time: "2019-01-01 01:00:00"},
    {id: 2, start_time: "2019-01-01 00:30:00" , end_time: "2019-01-01 01:30:00"},
    {id: 3, start_time: "2019-01-01 00:30:00" , end_time: "2019-01-01 02:00:00"},
    {id: 4, start_time: "2019-01-01 02:30:00" , end_time: "2019-01-01 03:01:00"},
]

I need a way to generate a report showing the maximum total number of jobs running for a specified granularity.

For example for a 30 min interval the result would look like this:

"2019-01-01 00:00:00": 1
"2019-01-01 00:30:00": 3
"2019-01-01 01:00:00": 3
"2019-01-01 01:30:00": 1
"2019-01-01 02:00:00": 0
"2019-01-01 02:30:00": 1
"2019-01-01 03:00:00": 1

This would mean that in that 30 min there was a max of so many jobs running.
I can't seem to find any way to aggregate the data in elastic search to obtain this. Am i looking wrong at this? Is there a better way to save this data to the index?

Thanks,
Daniel

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