cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Transposing the service ID with its name using DQL

walkadda
Newcomer

I have the following DQL query in my dashboard:

fetch dt.entity.host
| fields entity.name, runs
| fieldsFlatten runs
| filter in(runs.dt.entity.service, $services)
| fields entity.name, runs.dt.entity.service

The $services variable returns a list of service IDs, i.e "SERVICE-C1917273162D91".

I would like the query to return a table of hosts and their corresponding services, using hostnames and service names. Here is an example of what I'm trying to achieve:

hostnameservice
server-01myservice, anotherservice, yetanotherservice
server-02myservice
server-03anotherservice, yetanotherotherservice

 

But the actual result I get is:

entity.nameruns.dt.entity.service
server-01SERVICE-C912138912D19, SERVICE-C1298314717J89, SERVICE-G821398124921B90
server-02SERVICE-C1298314717J89
server-03SERVICE-C1298314717J89, SERVICE-G821398124921B90

 

I have tried using the "lookup" function, but did not have any luck.

fetch dt.entity.service
| filter in(id, runs.dt.entity.host)
], lookupField:id, sourceField:runs.dt.entity.host

How can I display the name of the service in this table instead, whilst keeping the relationship between the host and its services?

Thanks in advance

2 REPLIES 2

Hi @walkadda ,

 

you can try this probably this will work ?

fetch dt.entity.host
| fields entity.name, runs
| fieldsFlatten runs
| filter in(runs.dt.entity.service, $SERVICE)
| expand runs.dt.entity.service
| fields entity.name, runs.dt.entity.service
|fieldsAdd service_name = lookup([fetch dt.entity.service],
sourceField:runs.dt.entity.service, lookupField:id)[entity.name]

Screenshot 2025-06-24 at 11.43.31 AM.png

 

Br

!!! Dynatrace !!!

TracingMySanity
Observer

If you're filtering by service to look for the hosts it runs on, similar to @Akhil-Jayendran's solution, you can query the `runs_on` relationship on the service entity.

fetch dt.entity.service
| filter id == "SERVICE-FFB92DD67873FAC7"
| fieldsAdd runsOn = runs_on[dt.entity.host]
| filter isNotNull(runsOn)
| expand runsOn
| fields serviceName = entity.name, hostName = entityName(runsOn, type:"dt.entity.host")

TracingMySanity_1-1750785658999.png

 

 

Featured Posts