# Changing affected\_entity\_ids for entity name

**URL:** <https://community.dynatrace.com/t/changing-affected-entity-ids-for-entity-name/42139>\
**Category:** DQL\
**Tags:** dql, dashboards\
**Created:** [October 17, 2023, 8:25pm UTC](https://community.dynatrace.com/t/changing-affected-entity-ids-for-entity-name/42139 "2023-10-17T20:25:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![EnnioCamacho](https://avatars.discourse-cdn.com/v4/letter/e/f6c823/32.png) [@EnnioCamacho](https://community.dynatrace.com/u/EnnioCamacho)\
**Post date:** [October 17, 2023, 8:25pm UTC](https://community.dynatrace.com/t/changing-affected-entity-ids-for-entity-name/42139/1 "2023-10-17T20:25:34Z")

</div>

Hello!

Searching for help with the following, i’m relatively new using DQL. I have the following code, what i want is to display the entity names on the affected\_entity\_ids row, not the id, so far i have tried to change the affected\_entity for dt.entity values but no luck so far, any ideas how i could change the values on that field?

Code:

fetch events, from: timestamp(year:2023,month:10,day:16,hour:0,minute:0,second:0), to: timestamp(year:2023,month:10,day:16,hour:23,minute:59,second:0)  
| filter event.kind == “DAVIS\_PROBLEM”  
|expand event.name  
|summarize by:{event.name,affected\_entity\_ids}, count = countDistinct(display\_id)  
|sort count, direction:“descending”

Result:

 ![EnnioCamacho_0-1697574219667.png](https://global.discourse-cdn.com/dynatrace/original/2X/e/e0e230b54f974d84c46955d288d33311344d5b58.png)

---

<div class="post-metadata">

**Author:** ![natanael\_mendes](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/natanael_mendes/32/15264_2.png) [@natanael\_mendes](https://community.dynatrace.com/u/natanael_mendes)\
**Post date:** [October 17, 2023, 8:51pm UTC](https://community.dynatrace.com/t/changing-affected-entity-ids-for-entity-name/42139/2 "2023-10-17T20:51:53Z")

</div>

You need to reference the type of entity like this example below

**fetch dt.entity.host** | fieldsAdd runs[dt.entity.process\_group]

---

<div class="post-metadata">

**Author:** ![EnnioCamacho](https://avatars.discourse-cdn.com/v4/letter/e/f6c823/32.png) [@EnnioCamacho](https://community.dynatrace.com/u/EnnioCamacho)\
**Post date:** [October 23, 2023, 7:32pm UTC](https://community.dynatrace.com/t/changing-affected-entity-ids-for-entity-name/42139/3 "2023-10-23T19:32:04Z")

</div>

Hello,

I’ve been trying to add the host entity with a lookup function since the first fetch i’m using it for the davis problem events, so far no luck, I’ve been trying to include the entity with the fieldsadd and the fieldrename but no luck, it does not write any records, could it be that the affected entity id does not match with other entities field?

---

<div class="post-metadata">

**Author:** ![EnnioCamacho](https://avatars.discourse-cdn.com/v4/letter/e/f6c823/32.png) [@EnnioCamacho](https://community.dynatrace.com/u/EnnioCamacho)\
**Post date:** [October 31, 2023, 4:48pm UTC](https://community.dynatrace.com/t/changing-affected-entity-ids-for-entity-name/42139/4 "2023-10-31T16:48:54Z")

</div>

I have something figured out for now, it might not be optimal but for now it’s working, my only issue now is that the results are not grouping by event name as it used to, but for now it works for the purpose i intend to use it.

fetch events  
| filter event.kind == “DAVIS\_PROBLEM”  
|expand affected\_entity\_ids  
|lookup sourceField:affected\_entity\_ids, lookupField:id, prefix:“service.”, [  
fetch dt.entity.service | fields id, name = entity.name]  
|lookup sourceField:affected\_entity\_ids, lookupField:id, prefix:“http.”, [  
fetch dt.entity.http\_check | fields id, name = entity.name]  
|lookup sourceField:affected\_entity\_ids, lookupField:id, prefix:“process.”, [  
fetch dt.entity.process\_group\_instance | fields id, name = entity.name]  
|lookup sourceField:affected\_entity\_ids, lookupField:id, prefix:“host.”, [  
fetch dt.entity.host| fields id, name = entity.name]  
|lookup sourceField:affected\_entity\_ids, lookupField:id, prefix:“mobile.”, [  
fetch dt.entity.mobile\_application | fields id, name = entity.name]  
|fieldsAdd componente = array(host.name, http.name, mobile.name, process.name, service.name)  
|summarize by:{`Problema` = event.name, `Componente`= componente }, count = countDistinct(display\_id)  
|sort count, direction:“descending”
