# Count "active" messages

**URL:** https://discuss.elastic.co/t/count-active-messages/224680
**Category:** Logstash
**Created:** [March 23, 2020, 1:51pm UTC](https://discuss.elastic.co/t/count-active-messages/224680 "2020-03-23T13:51:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![KevSex](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kevsex/32/29031_2.png) [@KevSex](https://discuss.elastic.co/u/KevSex)
#### Post date: [March 23, 2020, 1:51pm UTC](https://discuss.elastic.co/t/count-active-messages/224680/1 "2020-03-23T13:51:30Z")

</div>

I have a log source that sends an event when an alert is triggered `event.type: "Alert Started"`. Another event is triggered when the alert clears `event.type: "Alert Ended"`

I'm looking to know how best I can retrieve a count of "active" alerts. i.e. number of alerts that has yet to receive an `Alert Ended` event.

Any ideas?

Cheers!

---

<div class="post-metadata">

### Author: ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)
#### Post date: [March 23, 2020, 3:15pm UTC](https://discuss.elastic.co/t/count-active-messages/224680/2 "2020-03-23T15:15:57Z")

</div>

You might be able to send the "Alert Started" events straight through, then use an aggregate filter to match up the start and end events. If you set the document\_id (I am assuming you are writing to elasticsearch) you can overwrite the document once it has ended. Then in elasticsearch you can query the number of alerts that have not ended.

---

<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: [April 20, 2020, 3:15pm UTC](https://discuss.elastic.co/t/count-active-messages/224680/3 "2020-04-20T15:15:58Z")

</div>

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