# Querying services related to an entity

**URL:** <https://community.dynatrace.com/t/querying-services-related-to-an-entity/45198>\
**Category:** DQL\
**Tags:** dql, services-classic, processes, dashboards\
**Created:** [April 17, 2024, 10:32pm UTC](https://community.dynatrace.com/t/querying-services-related-to-an-entity/45198 "2024-04-17T22:32:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![soportetr](https://avatars.discourse-cdn.com/v4/letter/s/c6cbf5/32.png) [@soportetr](https://community.dynatrace.com/u/soportetr)\
**Post date:** [April 17, 2024, 10:32pm UTC](https://community.dynatrace.com/t/querying-services-related-to-an-entity/45198/1 "2024-04-17T22:32:38Z")

</div>

Hi everyone,

A customer has requested a particular functionality: to display in a table the list of services associated with a specific entity (hosts, processes, etc.).

I would like to know if it is possible to perform this task using DQL language. I would appreciate any guidance or examples that you can provide me in this regard.

Thanks in advance

---

<div class="post-metadata">

**Author:** ![krzysztof\_hoja](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/krzysztof_hoja/32/34625_2.png) [@krzysztof\_hoja](https://community.dynatrace.com/u/krzysztof_hoja)\
**Post date:** [April 18, 2024, 4:24pm UTC](https://community.dynatrace.com/t/querying-services-related-to-an-entity/45198/2 "2024-04-18T16:24:26Z")

</div>

You can use DQL native syntax:

```markup
fetch dt.entity.service
| filter matchesValue(runs_on[dt.entity.process_group],"PROCESS_GROUP-140E7EA6D10A29E1")

```

But such queries can be slow until entites are stored in Grail too.

For now we recommend using _ **classicEntitySelector** _ function (where syntax of the filter should be known from classic Data Explorer which is BTW good place to test such expressions). Same result can be achieved this way:

```markup
fetch dt.entity.service
| filter in(id, classicEntitySelector("type(service),fromRelationship.runsOn(type(PROCESS_GROUP),entityId(\"PROCESS_GROUP-140E7EA6D10A29E1\"))"))

```

You can explore relationship of specific service from its perspective:

```markup
fetch dt.entity.service
| filter id=="SERVICE-086610B2358E4225"
| fieldsAdd runs_on

```

Then you get run\_on showing all entities service runs on:

 ![krzysztof_hoja_0-1713457429429.png](https://global.discourse-cdn.com/dynatrace/original/2X/c/cfec1998d88513950b153a6a82838401ba2cd439.png)

Kris

---

<div class="post-metadata">

**Author:** ![soportetr](https://avatars.discourse-cdn.com/v4/letter/s/c6cbf5/32.png) [@soportetr](https://community.dynatrace.com/u/soportetr)\
**Post date:** [April 24, 2024, 4:17pm UTC](https://community.dynatrace.com/t/querying-services-related-to-an-entity/45198/3 "2024-04-24T16:17:22Z")

</div>

Hi,

I managed to execute the query, however, a complex record appears and I don’t get the results as you do. I share with you the following screenshot

 ![query-related-service.png](https://global.discourse-cdn.com/dynatrace/original/3X/d/b/db6a8b6784a3af553ae2397aab611f4eba1bfb2b.png)

Soport

---

<div class="post-metadata">

**Author:** ![krzysztof\_hoja](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/krzysztof_hoja/32/34625_2.png) [@krzysztof\_hoja](https://community.dynatrace.com/u/krzysztof_hoja)\
**Post date:** [April 24, 2024, 4:30pm UTC](https://community.dynatrace.com/t/querying-services-related-to-an-entity/45198/4 "2024-04-24T16:30:01Z")

</div>

My screenshot was take in Notebooks app where you can click on “complex record” and see what is inside (show link to menu):

 ![krzysztof_hoja_0-1713975938504.png](https://global.discourse-cdn.com/dynatrace/original/2X/f/f547227060e6c4b7b65a4a34df0e5c10949ebec4.png)

I checked and Dashboard app does not have such functionality.

But when you know how fields are named in complex record, you can always extract them from it this way:

```markup
| fieldsAdd runs_on[dt.entity.host]

```

Result in Dashboards looks like this

 ![krzysztof_hoja_1-1713976104077.png](https://global.discourse-cdn.com/dynatrace/original/2X/e/e88a7f14499bcce8d8498758646e63ae66011a39.png)

---

<div class="post-metadata">

**Author:** ![soportetr](https://avatars.discourse-cdn.com/v4/letter/s/c6cbf5/32.png) [@soportetr](https://community.dynatrace.com/u/soportetr)\
**Post date:** [October 9, 2024, 4:54am UTC](https://community.dynatrace.com/t/querying-services-related-to-an-entity/45198/5 "2024-10-09T04:54:33Z")

</div>

Hi,

Is it possible to run a DQL that displays the incoming or outgoing services or entities related to a service?
