# Agent.hostname unique search

**URL:** <https://discuss.elastic.co/t/agent-hostname-unique-search/194245>\
**Category:** Elasticsearch\
**Created:** [August 7, 2019, 1:37pm UTC](https://discuss.elastic.co/t/agent-hostname-unique-search/194245 "2019-08-07T13:37:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jwwags92](https://avatars.discourse-cdn.com/v4/letter/j/f6c823/32.png) [@jwwags92](https://discuss.elastic.co/u/jwwags92)\
**Post date:** [August 7, 2019, 1:37pm UTC](https://discuss.elastic.co/t/agent-hostname-unique-search/194245/1 "2019-08-07T13:37:49Z")

</div>

Hi,

I'm forwarding event logs for 75 servers to elasticsearch. I would like to be able to run a query that lets me check the past 24 hours for all the UNIQUE entries in the agent.hostnames field. It should come back with...75 names!

is a there way to do this!?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 9, 2019, 6:18am UTC](https://discuss.elastic.co/t/agent-hostname-unique-search/194245/2 "2019-08-09T06:18:30Z")

</div>

Hey,

using aggregations is the way to go here. One way would be to use the [cardinality aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/search-aggregations-metrics-cardinality-aggregation.html) (make sure to read the docs about this one being probabilistic) or use an [terms aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/7.3/search-aggregations-bucket-terms-aggregation.html) if you interested in concrete values.

--Alex

---

<div class="post-metadata">

**Author:** ![jwwags92](https://avatars.discourse-cdn.com/v4/letter/j/f6c823/32.png) [@jwwags92](https://discuss.elastic.co/u/jwwags92)\
**Post date:** [August 9, 2019, 3:04pm UTC](https://discuss.elastic.co/t/agent-hostname-unique-search/194245/3 "2019-08-09T15:04:38Z")

</div>

Thank you for replying Alex. I will read the docs.

---

<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:** [September 6, 2019, 3:15pm UTC](https://discuss.elastic.co/t/agent-hostname-unique-search/194245/4 "2019-09-06T15:15:03Z")

</div>

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