# Concurrent running jobs histogram query

**URL:** <https://discuss.elastic.co/t/concurrent-running-jobs-histogram-query/176362>\
**Category:** Elasticsearch\
**Created:** [April 11, 2019, 9:09am UTC](https://discuss.elastic.co/t/concurrent-running-jobs-histogram-query/176362 "2019-04-11T09:09:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![photonstudio](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/photonstudio/32/43919_2.png) [@photonstudio](https://discuss.elastic.co/u/photonstudio)\
**Post date:** [April 11, 2019, 9:09am UTC](https://discuss.elastic.co/t/concurrent-running-jobs-histogram-query/176362/1 "2019-04-11T09:09:56Z")

</div>

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

---

<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:** [May 9, 2019, 9:09am UTC](https://discuss.elastic.co/t/concurrent-running-jobs-histogram-query/176362/2 "2019-05-09T09:09:56Z")

</div>

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