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

Why Does My DQL Query Fail to Return CPU Data for Certain Services? (ProcessGroup Instance Related to Service)

VictorRuiz
Contributor

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:

VictorRuiz_3-1751552904997.png

Doesn't work:

VictorRuiz_4-1751552938848.png

  • All the services in question belong to the same ProcessGroup, but their service types differ. Could this be contributing to the problem?



VictorRuiz_2-1751552812877.png

 

Any help or suggestions would be greatly appreciated, thank you very much in advance!

Victor

1 REPLY 1

marco_irmer
Champion

There's a simpler way to do this that I hope will work for you. The query happens in three steps:

  1. Grab the timeseries data for the process group instances. This is the first few lines of your existing query.
  2. Use the fieldsAdd command with the entityAttr() function to grab the entity relationship data as a new field. This replaces all the lookup stuff.
  3. Filter the list down to only show processes of interest and which host the service(s) in question, as you were pretty much doing already.

The DQL comes out like 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)`),
    services = entityAttr(dt.entity.process_group_instance,"runs")[dt.entity.service]
| filter in(services,$Service)

Here's a snapshot of the output when filtered down to a single service ID:

marco_irmer_0-1752101608794.png

 

Featured Posts