DQL
Questions about Dynatrace Query Language
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Entity Names in DQL

Pablo2
Participant

I have the following DQL to retrieve entities related to a host, but I need to know the entity name and not the IDs. Is there any way to obtain them?

fetch dt.entity.host
| filter entity.name == ‘DAMA2021.ppcloudmgmt.intraxa’
| fieldsAdd calls, called_by, instance_of, contains, runs, belongs_to

2 REPLIES 2

deni
Mentor

Hi @Pablo2 ,

fetch dt.entity.host
| fieldsFlatten calls
| expand callId = calls.dt.entity.host
| lookup sourceField: callId, lookupField: id,
    [ fetch dt.entity.host | fields id, entity.name ]
| summarize callNames = collectDistinct(lookup.entity.name), by:{id, entity.name }
| sort entity.name

 

I suppose you need something like this? It is only for calls, but can be extended for the other fields.

 

Regards, Deni

Dynatrace Integration Engineer at CodeAttest

t_pawlak
Champion

Hi @Pablo2 
@deni is right. Here are a few additional variants you can use depending on your needs:
Just the raw call IDs (split into rows):

fetch dt.entity.host
| filter entity.name == "easytravel-demo1"
| fieldsKeep id, entity.name, calls
| fieldsFlatten calls
| expand callId = calls.dt.entity.host
| fieldsKeep entity.name, callId

2. IDs + resolved entity names (with lookup):

fetch dt.entity.host
| filter entity.name == "easytravel-demo1"
| fieldsKeep id, entity.name, calls
| fieldsFlatten calls
| expand callId = calls.dt.entity.host
| lookup sourceField: callId, lookupField: id,
    [ fetch dt.entity.host | fields id, entity.name ]
| summarize callNames = collectDistinct(lookup.entity.name), by:{ id, entity.name }

3. Filtered by prefix/substring in the name:

fetch dt.entity.host
| filter entity.name == "easytravel-demo1"
| fieldsKeep id, entity.name, calls
| fieldsFlatten calls
| expand callId = calls.dt.entity.host
| lookup sourceField: callId, lookupField: id,
    [ fetch dt.entity.host | fields id, entity.name ]
| filter startsWith(lower(lookup.entity.name), "aks-")
| filter contains(lower(lookup.entity.name), "dynatrace.org")
| summarize callNames = collectDistinct(lookup.entity.name), by:{ id, entity.name }

4. One row per call (no aggregation, raw list):

fetch dt.entity.host
| filter entity.name == "easytravel-demo1"
| fieldsKeep id, entity.name, calls
| fieldsFlatten calls
| expand callId = calls.dt.entity.host
| filter isNull(callId) == false and callId != id
| lookup sourceField: callId, lookupField: id,
    [ fetch dt.entity.host | fields id, entity.name ]
| filter isNull(lookup.entity.name) == false
| fieldsKeep entity.name, callId, lookup.entity.name
| sort lookup.entity.name

Featured Posts