I have a dql that relates me the services and the hosts on which it is running, but it only gives me the id of the hosts and I would like to have the name of the host instead of the id.
You can use the entityName() function in place of the lookup function to get the host names. The other thing to account for is that the runs_on[dt.entity.host] field is an Array field. This means we need to expand the array before we use the entityName function. We can then summarize to form an array of host names. The DQL for this looks as follows:
fetch dt.entity.service
| expand dt.entity.host=runs_on[dt.entity.host]
| fieldsAdd host_name = entityName(dt.entity.host) // Add the host name
| summarize host_names = collectArray(host_name), by:{id,entity.name} // summarize to create a host_names array
| fieldsAdd entityAttr(dt.entity.host, "tags")
| filter in(id, classicEntitySelector(concat("type(service), tag(\"APP:", $APPLICATION, "\")")))
| filter in(id, classicEntitySelector(concat("type(service), tag(\"ENVIRONMENT:", $ENTORNO, "\")")))
// removed dedup command, as it is no longer needed after using the summarize command above