# Alerts/Rules - Elasticsearch query grouped on hostname

**URL:** <https://discuss.elastic.co/t/alerts-rules-elasticsearch-query-grouped-on-hostname/290145>\
**Category:** Kibana\
**Tags:** elastic-stack-alerting, detection-rules\
**Created:** [November 25, 2021, 9:03am UTC](https://discuss.elastic.co/t/alerts-rules-elasticsearch-query-grouped-on-hostname/290145 "2021-11-25T09:03:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Garry](https://avatars.discourse-cdn.com/v4/letter/g/bb73d2/32.png) [@Garry](https://discuss.elastic.co/u/Garry)\
**Post date:** [November 25, 2021, 9:03am UTC](https://discuss.elastic.co/t/alerts-rules-elasticsearch-query-grouped-on-hostname/290145/1 "2021-11-25T09:03:25Z")

</div>

I have an Elasticsearch query which emails out on an specific Windows Event Log event id.  
This is a basic query...  
{  
"query":{  
"query\_string" : {  
"query" : "10028",  
"fields": ["event.code"]

```
    }
}

```

}

What I would like to do is

1. Group alerts on host.name. So a separate alert for each host meeting this criteria.
2. Include the hostname in the emails.

Is an Elasticsearch query the best way to configure this?  
Any ideas?

---

<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 23, 2021, 9:03am UTC](https://discuss.elastic.co/t/alerts-rules-elasticsearch-query-grouped-on-hostname/290145/2 "2021-12-23T09:03:32Z")

</div>

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