# How do I add a filter to an Index Threshold alerting rule and alert per server?

**URL:** <https://discuss.elastic.co/t/how-do-i-add-a-filter-to-an-index-threshold-alerting-rule-and-alert-per-server/288519>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [November 5, 2021, 6:51pm UTC](https://discuss.elastic.co/t/how-do-i-add-a-filter-to-an-index-threshold-alerting-rule-and-alert-per-server/288519 "2021-11-05T18:51:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nsouth](https://avatars.discourse-cdn.com/v4/letter/n/ecccb3/32.png) [@nsouth](https://discuss.elastic.co/u/nsouth)\
**Post date:** [November 5, 2021, 6:51pm UTC](https://discuss.elastic.co/t/how-do-i-add-a-filter-to-an-index-threshold-alerting-rule-and-alert-per-server/288519/1 "2021-11-05T18:51:41Z")

</div>

I want to be alerted when our logs indicate that the average duration of commands is over 1 second. However, I cannot figure out how to do the following:

- Filter the query to only log events which have duration information (not all of them do)
- Alert _per server_. Logs for all servers are in the logs index and I want to know _which server_ is experiencing high command durations. The server ID is on a field in each record.

How can I accomplish these things? Here's a screenshot of my current rule definition. Thank you!

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/0/f0f9f33b0c9a326c47cc208628563c2d1eb11fea.png)

---

<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:** [December 3, 2021, 6:52pm UTC](https://discuss.elastic.co/t/how-do-i-add-a-filter-to-an-index-threshold-alerting-rule-and-alert-per-server/288519/2 "2021-12-03T18:52:33Z")

</div>

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