<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Why Does My DQL Query Fail to Return CPU Data for Certain Services? (ProcessGroup Instance Related to Service) in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Fix-DQL-Query-Issues-When-CPU-Data-Is-Missing-for-Hosts/m-p/281212#M2275</link>
    <description>&lt;P&gt;There's a simpler way to do this that I hope will work for you. The query happens in three steps:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Grab the timeseries data for the process group instances. This is the first few lines of your existing query.&lt;/LI&gt;&lt;LI&gt;Use the fieldsAdd command with the entityAttr() function to grab the entity relationship data as a new field. This replaces all the lookup stuff.&lt;/LI&gt;&lt;LI&gt;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.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;The DQL comes out like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;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)&lt;/LI-CODE&gt;&lt;P&gt;Here's a snapshot of the output when filtered down to a single service ID:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="marco_irmer_0-1752101608794.png" style="width: 811px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/28922iEC708208ACC7CAE1/image-dimensions/811x504?v=v2" width="811" height="504" role="button" title="marco_irmer_0-1752101608794.png" alt="marco_irmer_0-1752101608794.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 09 Jul 2025 22:56:49 GMT</pubDate>
    <dc:creator>marco_irmer</dc:creator>
    <dc:date>2025-07-09T22:56:49Z</dc:date>
    <item>
      <title>Fix DQL Query Issues When CPU Data Is Missing for Hosts</title>
      <link>https://community.dynatrace.com/t5/DQL/Fix-DQL-Query-Issues-When-CPU-Data-Is-Missing-for-Hosts/m-p/280728#M2247</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;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:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;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&lt;/LI-CODE&gt;
&lt;P&gt;What I expect the DQL do:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Calculate the average CPU consumption (avg(dt.process.cpu.usage)) for each ProcessGroup instance.&lt;/LI&gt;
&lt;LI&gt;Relate the Process to the service selected in the dashboard variable ($Service).&lt;/LI&gt;
&lt;LI&gt;Filter only the instances that have a specific tag (ENVIRONMENT:PRO).&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;I have tested the following:&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;Works:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VictorRuiz_3-1751552904997.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/28805i945198A17BEA5920/image-size/medium?v=v2&amp;amp;px=400" role="button" title="VictorRuiz_3-1751552904997.png" alt="VictorRuiz_3-1751552904997.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Doesn't work:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VictorRuiz_4-1751552938848.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/28806iF5F727BA10899DD4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="VictorRuiz_4-1751552938848.png" alt="VictorRuiz_4-1751552938848.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;All the services in question belong to the same ProcessGroup, but their&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;service types&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;differ. Could this be contributing to the problem?&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VictorRuiz_2-1751552812877.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/28804iE46941929DD50E6A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="VictorRuiz_2-1751552812877.png" alt="VictorRuiz_2-1751552812877.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help or suggestions would be greatly appreciated, thank you very much in advance!&lt;/P&gt;
&lt;P&gt;Victor&lt;/P&gt;</description>
      <pubDate>Thu, 18 Dec 2025 10:36:20 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Fix-DQL-Query-Issues-When-CPU-Data-Is-Missing-for-Hosts/m-p/280728#M2247</guid>
      <dc:creator>VictorRuiz</dc:creator>
      <dc:date>2025-12-18T10:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: Why Does My DQL Query Fail to Return CPU Data for Certain Services? (ProcessGroup Instance Related to Service)</title>
      <link>https://community.dynatrace.com/t5/DQL/Fix-DQL-Query-Issues-When-CPU-Data-Is-Missing-for-Hosts/m-p/281212#M2275</link>
      <description>&lt;P&gt;There's a simpler way to do this that I hope will work for you. The query happens in three steps:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Grab the timeseries data for the process group instances. This is the first few lines of your existing query.&lt;/LI&gt;&lt;LI&gt;Use the fieldsAdd command with the entityAttr() function to grab the entity relationship data as a new field. This replaces all the lookup stuff.&lt;/LI&gt;&lt;LI&gt;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.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;The DQL comes out like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;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)&lt;/LI-CODE&gt;&lt;P&gt;Here's a snapshot of the output when filtered down to a single service ID:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="marco_irmer_0-1752101608794.png" style="width: 811px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/28922iEC708208ACC7CAE1/image-dimensions/811x504?v=v2" width="811" height="504" role="button" title="marco_irmer_0-1752101608794.png" alt="marco_irmer_0-1752101608794.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jul 2025 22:56:49 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Fix-DQL-Query-Issues-When-CPU-Data-Is-Missing-for-Hosts/m-p/281212#M2275</guid>
      <dc:creator>marco_irmer</dc:creator>
      <dc:date>2025-07-09T22:56:49Z</dc:date>
    </item>
  </channel>
</rss>

