# Get counts of events happening(not ended) currently

**URL:** https://discuss.elastic.co/t/get-counts-of-events-happening-not-ended-currently/128915
**Category:** Kibana
**Created:** [April 20, 2018, 4:53pm UTC](https://discuss.elastic.co/t/get-counts-of-events-happening-not-ended-currently/128915 "2018-04-20T16:53:06Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![krishna\_chaitanya](https://avatars.discourse-cdn.com/v4/letter/k/b5a626/32.png) [@krishna\_chaitanya](https://discuss.elastic.co/u/krishna_chaitanya)
#### Post date: [April 20, 2018, 4:53pm UTC](https://discuss.elastic.co/t/get-counts-of-events-happening-not-ended-currently/128915/1 "2018-04-20T16:53:06Z")

</div>

I have set of data where each data point has `start_time` and `end_time`

Ex:  
`{"start_time":"2018-04-20T15:40:04.466Z","end_time":"2018-04-20T15:50:04.466Z"}`  
`{"start_time":"2018-04-20T15:41:04.466Z","end_time":"2018-04-20T15:47:04.466Z"}`  
`{"start_time":"2018-04-20T15:42:04.466Z","end_time":"2018-04-20T15:43:04.466Z"}`

I would like to get count of events happening(not ended) at a certain point of time.

Ex: If I have to find events happening exactly at `2018-04-20T15:45:00.000Z` the above set of data should return 2.

Furthermore, I want to get counts in 5 min interval. Ex: how many events happening( not ended) currently at 5th min, 10th min, 15th min, ....

Kibana version: 5.4  
Please let me know how this can be accomplished.

---

<div class="post-metadata">

### Author: ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)
#### Post date: [April 20, 2018, 5:17pm UTC](https://discuss.elastic.co/t/get-counts-of-events-happening-not-ended-currently/128915/2 "2018-04-20T17:17:53Z")

</div>

for the first example you could set a filter `start_time:>=2018-04-18T15:45:00.000Z AND end_time:<=2018-04-18T15:45:00.000Z`

---

<div class="post-metadata">

### Author: ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)
#### Post date: [April 20, 2018, 5:20pm UTC](https://discuss.elastic.co/t/get-counts-of-events-happening-not-ended-currently/128915/3 "2018-04-20T17:20:47Z")

</div>

for the second example .... you actually want counts and that specific time, not the average over the last 5,10,15 minutes ? so exactly at 15:00, 15:05, 15:10, ... ?

---

<div class="post-metadata">

### Author: ![krishna\_chaitanya](https://avatars.discourse-cdn.com/v4/letter/k/b5a626/32.png) [@krishna\_chaitanya](https://discuss.elastic.co/u/krishna_chaitanya)
#### Post date: [April 20, 2018, 5:31pm UTC](https://discuss.elastic.co/t/get-counts-of-events-happening-not-ended-currently/128915/4 "2018-04-20T17:31:19Z")

</div>

Yeah, exactly at certain times  
I just gave 5m as an example.  
I want to calculate at each minute, how many ongoing events are happening.

---

<div class="post-metadata">

### Author: ![ppisljar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ppisljar/32/11588_2.png) [@ppisljar](https://discuss.elastic.co/u/ppisljar)
#### Post date: [April 20, 2018, 6:03pm UTC](https://discuss.elastic.co/t/get-counts-of-events-happening-not-ended-currently/128915/5 "2018-04-20T18:03:07Z")

</div>

I don't think that's possible in kibana at the moment. You could get the number of documents started in some interval and substract the number of documents ended .... or even do a cumulative sum. But none of those are actually what you need.

---

<div class="post-metadata">

### Author: ![krishna\_chaitanya](https://avatars.discourse-cdn.com/v4/letter/k/b5a626/32.png) [@krishna\_chaitanya](https://discuss.elastic.co/u/krishna_chaitanya)
#### Post date: [April 24, 2018, 7:39pm UTC](https://discuss.elastic.co/t/get-counts-of-events-happening-not-ended-currently/128915/6 "2018-04-24T19:39:41Z")

</div>

yeah, I am using query like this for getting at certain time-10m ago.

`end_time:[now/m-10m TO *] AND start_time:[* TO now/m-10m}`

I created an alert which gets this value every 1 min, and index it back into Elasticsearch.

---

<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 22, 2018, 7:39pm UTC](https://discuss.elastic.co/t/get-counts-of-events-happening-not-ended-currently/128915/7 "2018-05-22T19:39:44Z")

</div>

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