# Using DQL or notebooks to pull the friendly name of relationships?

**URL:** <https://community.dynatrace.com/t/using-dql-or-notebooks-to-pull-the-friendly-name-of-relationships/46448>\
**Category:** DQL\
**Tags:** dql, notebooks\
**Created:** [July 3, 2024, 3:30pm UTC](https://community.dynatrace.com/t/using-dql-or-notebooks-to-pull-the-friendly-name-of-relationships/46448 "2024-07-03T15:30:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChadTurner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/chadturner/32/161_2.png) [@ChadTurner](https://community.dynatrace.com/u/ChadTurner)\
**Post date:** [July 3, 2024, 3:30pm UTC](https://community.dynatrace.com/t/using-dql-or-notebooks-to-pull-the-friendly-name-of-relationships/46448/1 "2024-07-03T15:30:36Z")

</div>

Is anyone aware of a DQL statement or notebook that can be formulated to dynamically give the friendly name of entities based off relationships?

For Example HostIDXXXXXX to/from relationships in the api we get the Dynatrace IDs. In the past we had to create an api that would take the result of the Host ID GET then submit multiple gets for the relationship items that were formulated from the first GET, just to get the friendly name.

 ![ChadTurner_0-1720020592694.png](https://global.discourse-cdn.com/dynatrace/original/2X/9/926213c6d2e61119021cb0c200d9fb5c4e9ada71.png)

---

<div class="post-metadata">

**Author:** ![Maheedhar\_T](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/maheedhar_t/32/155_2.png) [@Maheedhar\_T](https://community.dynatrace.com/u/Maheedhar_T)\
**Post date:** [July 3, 2024, 7:35pm UTC](https://community.dynatrace.com/t/using-dql-or-notebooks-to-pull-the-friendly-name-of-relationships/46448/2 "2024-07-03T19:35:46Z")

</div>

Hey&nbsp;[@ChadTurner](https://community.dynatrace.com/user/14877)&nbsp;,  
Not sure about the Host to process correlation but host to host can be done there are two fields in dql that you can use to filter when you do “fetch dt.entity.host” they are calls and called\_by which are pretty much self-explanatory.&nbsp;  
calls: The target hosts which our host is calling.  
called\_by: The hosts to which our host is the target host.  
So here’s the dql.

```markup
fetch dt.entity.host
| filter entity.detected_name == <Host's friendly name here>
| fields called_by
| expand called_by[dt.entity.host]
| lookup sourceField:`called_by[dt.entity.host]`, lookupField:id,[fetch dt.entity.host | fieldsAdd id]

```

maybe you can edit this and add calls and called\_by in the same query but yeah this is pretty much it.  
Hope this helps.

Regards,  
[@Maheedhar\_T](https://community.dynatrace.com/user/76275)

---

<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:** [July 4, 2024, 4:16pm UTC](https://community.dynatrace.com/t/using-dql-or-notebooks-to-pull-the-friendly-name-of-relationships/46448/3 "2024-07-04T16:16:09Z")

</div>

If I understand correctly, this could be a solution:

```markup
fetch dt.entity.host
| filter id == "HOST-6C867CD1BF3229B0"
| fieldsAdd dt.entity.process_group=runs[dt.entity.process_group]
| expand dt.entity.process_group
| fields dt.entity.process_group, dt.entity.process_group.name = entityName(dt.entity.process_group)

```

First get process groups entity IDs running on host and next lookup for their names. Result looks like this:

 ![krzysztof_hoja_0-1720109270777.png](https://global.discourse-cdn.com/dynatrace/original/3X/7/4/742443088d06bc22c77f4fac7f5be923b3da9528.png)

I used works “lookup” on purpose, because _ **entityName** _ (and similar _ **entityAttr** _) function is easy to use wrapper of for _ **lookup** _ command where you can get many more entity properties in one step:

```markup
fetch dt.entity.host
| filter id == "HOST-6C867CD1BF3229B0"
| fieldsAdd dt.entity.process_group=runs[dt.entity.process_group]
| expand dt.entity.process_group
| lookup [
  fetch dt.entity.process_group
  ], sourceField:dt.entity.process_group, lookupField:id, executionOrder:leftFirst,
  fields:{process_group.name=entity.name, process_group.softwareTechnologies=softwareTechnologies}
| fields dt.entity.process_group, process_group.name, process_group.softwareTechnologies

```

 ![krzysztof_hoja_1-1720109700514.png](https://global.discourse-cdn.com/dynatrace/original/2X/a/a381ae68467e1a1ba1b7f8e4a92767cc49418657.png)

Kris

---

<div class="post-metadata">

**Author:** ![ChadTurner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/chadturner/32/161_2.png) [@ChadTurner](https://community.dynatrace.com/u/ChadTurner)\
**Post date:** [July 8, 2024, 1:46pm UTC](https://community.dynatrace.com/t/using-dql-or-notebooks-to-pull-the-friendly-name-of-relationships/46448/4 "2024-07-08T13:46:55Z")

</div>

Thank you all for your help on this!
