# How to use entitySelector() to query by host in Data Explorer?

**URL:** <https://community.dynatrace.com/t/how-to-use-entityselector-to-query-by-host-in-data-explorer/42276>\
**Category:** Open Q&A\
**Tags:** dynatrace-managed\
**Created:** [October 25, 2023, 1:41pm UTC](https://community.dynatrace.com/t/how-to-use-entityselector-to-query-by-host-in-data-explorer/42276 "2023-10-25T13:41:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![EvaWang](https://avatars.discourse-cdn.com/v4/letter/e/e9c0ed/32.png) [@EvaWang](https://community.dynatrace.com/u/EvaWang)\
**Post date:** [October 25, 2023, 1:41pm UTC](https://community.dynatrace.com/t/how-to-use-entityselector-to-query-by-host-in-data-explorer/42276/1 "2023-10-25T13:41:11Z")

</div>

when I query in Data explorer:

1. I used “ **builtin:billing.ddu.log.byEntity** ” query and returned 91 records:

 ![EvaWang_0-1698240750585.png](https://global.discourse-cdn.com/dynatrace/original/3X/b/5/b57e855dea290dc8c4fac8da812ec40d33ffa3b3.png)

2.&nbsp;then add filter in this query “**builtin:billing.ddu.log.byEntity:filter(in(“dt.entity.monitored\_entity”, entitySelector(“type(~“HOST~”)”)))**” returned “No data” and no hint of syntax error:

 ![EvaWang_1-1698240767739.png](https://global.discourse-cdn.com/dynatrace/original/3X/f/3/f39ef80748d14e1fe1c017864fa3cbac8f6943ca.png)

3.&nbsp; and the details exported using API, all the malricids written are “PROCESS\_GROUP\_INSTANCE-???”:

 ![EvaWang_2-1698240785891.png](https://global.discourse-cdn.com/dynatrace/original/2X/0/0bd0c490253031455326aa82299a61e7d6aa57cf.png)

**May I ask** : is it because ddu.log metric cannot express the data by host? or am i using the wrong query? If I can use “entitySelector” in Metric query, I could query many different entities such as : gateway, cloud instances, services, etc. So please help me.

---

<div class="post-metadata">

**Author:** ![victor\_balbuena](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/victor_balbuena/32/9773_2.png) [@victor\_balbuena](https://community.dynatrace.com/u/victor_balbuena)\
**Post date:** [October 25, 2023, 1:59pm UTC](https://community.dynatrace.com/t/how-to-use-entityselector-to-query-by-host-in-data-explorer/42276/2 "2023-10-25T13:59:12Z")

</div>

That is correct, the split of the dimension is done by process group instance, and not by host. Because of this, you can’t split by host on this metric, but you can filter by a specific host or set of hosts by using relationships in the entity selector. For example, in your case, it might look something like:

**builtin:billing.ddu.log.byEntity:filter(in(“dt.entity.monitored\_entity”, entitySelector(type(PROCESS\_GROUP\_INSTANCE),fromRelationships.isProcessOf(type(HOST),entityId(\<HOST-ID\>)))))**

Instead of&nbsp; **entityId** you can then use whatever entity selector filter you want in there for your host, as per [the documentation](https://www.dynatrace.com/support/help/dynatrace-api/environment-api/entity-v2/entity-selector).

---

<div class="post-metadata">

**Author:** ![AntonPineiro](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/antonpineiro/32/49_2.png) [@AntonPineiro](https://community.dynatrace.com/u/AntonPineiro)\
**Post date:** [October 25, 2023, 5:01pm UTC](https://community.dynatrace.com/t/how-to-use-entityselector-to-query-by-host-in-data-explorer/42276/3 "2023-10-25T17:01:33Z")

</div>

Hi,

What happens if you add “:parents”, something as “builtin:billing.ddu.log.byEntity\*\*:parents\*\*”

Best regards
