Hi all,
I am working on a Dynatrace dashboard and I need to get the average CPU consumption of the ProcessGroups instances associated to the selected service in a dashboard variable. I am using the following DQL script to achieve this:
timeseries avg(dt.process.cpu.usage), by: { dt.entity.process_group_instance, dt.entity.process_group }
| fieldsAdd
dt.entity.process_group_instance.name = entityName(dt.entity.process_group_instance),
dt.entity.process_group.name = entityName(dt.entity.process_group),
value.CPU = arrayAvg(`avg(dt.process.cpu.usage)`)
| lookup [
fetch dt.entity.service
| fields entity.name, id, runs_on
| fieldsFlatten runs_on
], sourceField: dt.entity.process_group, lookupField: runs_on.dt.entity.process_group
| fieldsAdd monitor_tags = toString(entityAttr(dt.entity.process_group_instance, "tags"))
| filter contains(monitor_tags, "ENVIRONMENT:PRO")
| filter lookup.entity.name == $Service
What I expect the DQL do:
- Calculate the average CPU consumption (avg(dt.process.cpu.usage)) for each ProcessGroup instance.
- Relate the Process to the service selected in the dashboard variable ($Service).
- Filter only the instances that have a specific tag (ENVIRONMENT:PRO).
The DQL works correctly for some services, but for others it returns “no data”. However, by manually inspecting the service in question, I can see that it has ProcessGroups and instances that should be generating CPU data. There are even ProcessGroups identical to those of services that do work correctly with the script.
This makes me think that there may be some problem with how the relationship between the entities is done (for example, in the lookup step) or with the filtering.
I have tested the following:
I have made sure that the service selected in $Service has links to ProcessGroups that generate CPU data and I have tested the script with multiple different services to confirm that it is not a global problem but it happens without a clear pattern.
Works:
Doesn’t work:
- All the services in question belong to the same ProcessGroup, but their service types differ. Could this be contributing to the problem?
Any help or suggestions would be greatly appreciated, thank you very much in advance!
Victor



