<?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 DQL - get the top 5 process of each host in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/DQL-get-the-top-5-process-of-each-host/m-p/213886#M91</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am now facing a problem when writing the DQL query to get the top 5 processes of each host in an 1-hour interval.&lt;/P&gt;&lt;P&gt;Here is the DQL that I come up with:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;timeseries max(dt.process.cpu.usage), 
by:{host.name, dt.process_group_instance}, 
interval:1h, 
from:-2h, 
to:now()
| limit 5&lt;/LI-CODE&gt;&lt;P&gt;But seems like the logic is not correct.&amp;nbsp; If I add "limit 5", it only shows me 5 records in total.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need the host name and process name in the result.&lt;/P&gt;&lt;P&gt;Grateful if anyone can help on the this issue.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Thu, 01 Jun 2023 17:40:13 GMT</pubDate>
    <dc:creator>StephenLHChan</dc:creator>
    <dc:date>2023-06-01T17:40:13Z</dc:date>
    <item>
      <title>DQL - get the top 5 process of each host</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-get-the-top-5-process-of-each-host/m-p/213886#M91</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am now facing a problem when writing the DQL query to get the top 5 processes of each host in an 1-hour interval.&lt;/P&gt;&lt;P&gt;Here is the DQL that I come up with:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;timeseries max(dt.process.cpu.usage), 
by:{host.name, dt.process_group_instance}, 
interval:1h, 
from:-2h, 
to:now()
| limit 5&lt;/LI-CODE&gt;&lt;P&gt;But seems like the logic is not correct.&amp;nbsp; If I add "limit 5", it only shows me 5 records in total.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need the host name and process name in the result.&lt;/P&gt;&lt;P&gt;Grateful if anyone can help on the this issue.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jun 2023 17:40:13 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-get-the-top-5-process-of-each-host/m-p/213886#M91</guid>
      <dc:creator>StephenLHChan</dc:creator>
      <dc:date>2023-06-01T17:40:13Z</dc:date>
    </item>
    <item>
      <title>Re: DQL - get the top 5 process of each host</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-get-the-top-5-process-of-each-host/m-p/213913#M92</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/59527"&gt;@StephenLHChan&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;this is the query I suggest for your use case:&lt;/P&gt;
&lt;PRE&gt;timeseries cpuUsage = avg(dt.process.cpu.usage), by:{host.name, dt.entity.process_group_instance}, interval:1h, from:-2h, to:now()&lt;BR /&gt;| sort arrayAvg(cpuUsage) desc&lt;BR /&gt;| limit 5&lt;BR /&gt;| lookup [fetch dt.entity.process_group_instance], sourceField:dt.entity.process_group_instance, lookupField:id&lt;BR /&gt;| fieldsRename process_group_instance.name = lookup.entity.name&lt;BR /&gt;| fieldsRemove lookup.id, dt.entity.process_group_instance&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="stefan_eggersto_0-1685689408471.png" style="width: 999px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/12040i8E432D41FFD52278/image-size/large?v=v2&amp;amp;px=999" role="button" title="stefan_eggersto_0-1685689408471.png" alt="stefan_eggersto_0-1685689408471.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Let's break this down:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;you need a &lt;CODE&gt;lookup&lt;/CODE&gt; command to get from the PGI id on the timeseries to the name of the PGI&lt;/LI&gt;
&lt;LI&gt;you are most likely looking for the processes with the highest average CPU in the selected timeframe. Therefore, use &lt;CODE&gt;avg&lt;/CODE&gt; as aggregation in the timeseries command, and combine it with &lt;CODE&gt;sort arrayAvg(cpuUsage) desc&lt;/CODE&gt;, which calculates the average for each process in the whole timeframe, and the sorts by that values descending.&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;fieldsRename&lt;/CODE&gt; is only used to get a nicer name (instead of the default of &lt;CODE&gt;lookup.entity.name&lt;/CODE&gt;)&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;fieldsRemove&lt;/CODE&gt; is used to remove the PGI id fields to have a simpler series label&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Let me know if this helps!&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 07:21:51 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-get-the-top-5-process-of-each-host/m-p/213913#M92</guid>
      <dc:creator>stefan_eggersto</dc:creator>
      <dc:date>2023-06-02T07:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: DQL - get the top 5 process of each host</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-get-the-top-5-process-of-each-host/m-p/213958#M93</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/9516"&gt;@stefan_eggersto&lt;/a&gt;&amp;nbsp;for the reply.&lt;/P&gt;&lt;P&gt;I really appreciate your help.&lt;/P&gt;&lt;P&gt;I may not ask the question correctly.&amp;nbsp; Below is what the final result I want will be.&lt;/P&gt;&lt;P&gt;The goal is for each host monitored in Dynatrace, get the top 5 processes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not all the fields are needed to be the same at the DQL results as long as I can some transform jobs on it and get it.&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="12.5%" height="30px"&gt;Time_from&lt;/TD&gt;&lt;TD width="12.5%" height="30px"&gt;Time_to&lt;/TD&gt;&lt;TD width="25%" height="30px"&gt;Host name&lt;/TD&gt;&lt;TD width="25%" height="30px"&gt;Process name&lt;/TD&gt;&lt;TD width="25%" height="30px"&gt;value&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="12.5%" height="57px"&gt;2023-06-02 07:00&lt;/TD&gt;&lt;TD width="12.5%" height="57px"&gt;2023-06-02 08:00&lt;/TD&gt;&lt;TD width="25%" height="57px"&gt;Host A&lt;/TD&gt;&lt;TD width="25%" height="57px"&gt;Process A&lt;/TD&gt;&lt;TD width="25%" height="57px"&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="12.5%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="12.5%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="30px"&gt;Process B&lt;/TD&gt;&lt;TD width="25%" height="30px"&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="12.5%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="12.5%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="30px"&gt;Process C&lt;/TD&gt;&lt;TD width="25%" height="30px"&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="12.5%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="12.5%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="30px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="30px"&gt;Process D&lt;/TD&gt;&lt;TD width="25%" height="30px"&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="12.5%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="12.5%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;Process E&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;&lt;P&gt;6&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="12.5%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="12.5%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;Host B&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;Process F&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;&lt;P&gt;12&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="12.5%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="12.5%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;Process B&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;&lt;P&gt;10&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="12.5%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="12.5%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;Process K&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;&lt;P&gt;8&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="12.5%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="12.5%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;Process L&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;&lt;P&gt;6&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="12.5%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="12.5%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;Process I&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;&lt;P&gt;4&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="12.5%" height="84px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="12.5%" height="84px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="84px"&gt;... and then all hosts or I will add a filter to select only the osType is LINUX&lt;/TD&gt;&lt;TD width="25%" height="84px"&gt;...&lt;/TD&gt;&lt;TD width="25%" height="84px"&gt;&lt;P&gt;...&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="12.5%" height="57px"&gt;2023-06-02 08:00&lt;/TD&gt;&lt;TD width="12.5%" height="57px"&gt;2023-06-02 09:00&lt;/TD&gt;&lt;TD width="25%" height="57px"&gt;Host A&lt;/TD&gt;&lt;TD width="25%" height="57px"&gt;Process A&lt;/TD&gt;&lt;TD width="25%" height="57px"&gt;&lt;P&gt;11&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="12.5%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="12.5%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;Process F&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="30px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD height="30px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD height="30px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD height="30px"&gt;Process L&lt;/TD&gt;&lt;TD height="30px"&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Process O&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Process I&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="12.5%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="12.5%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;Host B&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;Process Z&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;&lt;P&gt;12&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="12.5%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="12.5%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;Process U&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;&lt;P&gt;10&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="12.5%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="12.5%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;Process K&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;&lt;P&gt;8&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="12.5%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="12.5%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;Process L&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;&lt;P&gt;6&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="12.5%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="12.5%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;Process I&lt;/TD&gt;&lt;TD width="25%" height="40px"&gt;&lt;P&gt;4&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;TD&gt;...&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;...&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I want to know the limitation for DQL. I tried to execute it at Notebook and also '/query:execute' API.&amp;nbsp;&amp;nbsp;Below error was shown.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StephenLHChan_0-1685715774807.png" style="width: 999px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/12047i9474722FFA7531B3/image-size/large?v=v2&amp;amp;px=999" role="button" title="StephenLHChan_0-1685715774807.png" alt="StephenLHChan_0-1685715774807.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 14:34:39 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-get-the-top-5-process-of-each-host/m-p/213958#M93</guid>
      <dc:creator>StephenLHChan</dc:creator>
      <dc:date>2023-06-02T14:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: DQL - get the top 5 process of each host</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-get-the-top-5-process-of-each-host/m-p/213967#M94</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/59527"&gt;@StephenLHChan&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This query should work for you&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;timeseries cpuUsage = avg(dt.process.cpu.usage),  
  by:{host.name, dt.entity.process_group_instance, dt.entity.host}, interval:1h, from:-2h, to:now()
| lookup [
  timeseries cpuUsage = avg(dt.process.cpu.usage),  
    by:{host.name, dt.entity.host, dt.entity.process_group_instance},interval:1h, from:-2h, to:now()
  | fieldsAdd cpuUsage = arrayAvg(cpuUsage)
  | filter cpuUsage != 0
  | sort dt.entity.host asc, cpuUsage desc
  | summarize cpu=collectArray(cpuUsage), by: dt.entity.host
  | fieldsadd threshold= if(arraySize(cpu)&amp;gt;= 5,cpu[4],else:0)
  | fieldsadd threshold= if(arraySize(cpu) == 4,cpu[3],else:threshold)
  | fieldsadd threshold=if(arraySize(cpu)== 3,cpu[2],else:threshold)
  | fieldsadd threshold=if(arraySize(cpu)== 2,cpu[1],else:threshold)
  | fieldsadd threshold=if(arraySize(cpu)== 1,cpu[0],else:threshold)
  | fields dt.entity.host, threshold
], sourceField:dt.entity.host, lookupField:dt.entity.host
| filter arrayAvg(cpuUsage) &amp;gt;= lookup.threshold
| fields cpuUsage, host.name, timeframe, interval, dt.entity.process_group_instance
| lookup [fetch dt.entity.process_group_instance], sourceField:dt.entity.process_group_instance, lookupField:id
| fieldsRename process_group_instance.name = lookup.entity.name
| fieldsRemove lookup.id
| sort host.name asc, cpuUsage desc
| fields start=timeframe[start], end=timeframe[end], Host=host.name, Process=process_group_instance.name, arrayAvg(cpuUsage) &lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have adapted the query a bit. For every process, I am doing here a lookup to find out what is the cpu threshold of the top processes on the host.&amp;nbsp; After you have the threshold, you just filter to be above or equal to the top5 processes.&lt;/P&gt;
&lt;P&gt;Regarding DQL limitations and the lookup command. One of its main purposes is to "lookup" the entity name for a certain entity id. So it is not a proper join command as you might know it from SQL. Therefore it has a limit when it comes to reading data.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;BR /&gt;Sini&lt;/P&gt;</description>
      <pubDate>Fri, 02 Jun 2023 16:52:11 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-get-the-top-5-process-of-each-host/m-p/213967#M94</guid>
      <dc:creator>sinisa_zubic</dc:creator>
      <dc:date>2023-06-02T16:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: DQL - get the top 5 process of each host</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-get-the-top-5-process-of-each-host/m-p/214088#M95</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/38283"&gt;@sinisa_zubic&lt;/a&gt; for the reply.&lt;/P&gt;&lt;P&gt;I am not sure if my understanding to your DQL query is correct or not. seems like the top 5 processes of a host will always be the same for the 2 hours. The result is something like:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="20%"&gt;time_from&lt;/TD&gt;&lt;TD width="20%"&gt;time_to&lt;/TD&gt;&lt;TD width="20%"&gt;host name&lt;/TD&gt;&lt;TD width="20%"&gt;process name&lt;/TD&gt;&lt;TD width="20%"&gt;value&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="20%"&gt;&lt;SPAN&gt;2023-06-02 0&lt;FONT color="#FF0000"&gt;7&lt;/FONT&gt;:00&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="20%"&gt;&lt;SPAN&gt;2023-06-02 0&lt;FONT color="#FF0000"&gt;9&lt;/FONT&gt;:00&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD width="20%"&gt;Host A&lt;/TD&gt;&lt;TD width="20%"&gt;Process C&lt;/TD&gt;&lt;TD width="20%"&gt;[ 12, 10]&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;For each hour, I want to get the top 5 process of each host.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regarding the limitation of DQL, seems like the number of dt.entity.process_group_instance is too large in my company.&lt;/P&gt;&lt;P&gt;Every time I added:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| lookup [fetch dt.entity.process_group_instance], sourceField:dt.entity.process_group_instance, lookupField:id
| fieldsRename process_group_instance.name = lookup.entity.name
| fieldsRemove lookup.id&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it will always show the error.&lt;/P&gt;&lt;P&gt;I will try out other way to pass the name to the result.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jun 2023 19:49:11 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-get-the-top-5-process-of-each-host/m-p/214088#M95</guid>
      <dc:creator>StephenLHChan</dc:creator>
      <dc:date>2023-06-05T19:49:11Z</dc:date>
    </item>
    <item>
      <title>Re: DQL - get the top 5 process of each host</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-get-the-top-5-process-of-each-host/m-p/214758#M96</link>
      <description>&lt;P&gt;Below may be a solution that can get the process name.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;fetch dt.entity.process_group_instance
| lookup [
  timeseries cpuUsage = avg(dt.process.cpu.usage),  
  by:{host.name, dt.entity.process_group_instance, dt.entity.host, process.name}, 
  interval:1h, 
  from: "2023-06-02T18:00:00.000Z", 
  to: "2023-06-02T19:00:00.000Z"
  | filter startsWith(dt.entity.host, "HOST-A")
  | lookup [
    timeseries cpuUsage = avg(dt.process.cpu.usage),  
      by:{host.name, dt.entity.host, dt.entity.process_group_instance},interval:1h, from:"2023-06-02T18:00:00.000Z", to:"2023-06-02T19:00:00.000Z"
    | fieldsAdd cpuUsage = arrayAvg(cpuUsage)
    | filterOut  cpuUsage == 0
    | sort dt.entity.host asc, cpuUsage desc
    | summarize cpu = collectArray(cpuUsage), by: {dt.entity.host}
    | fieldsAdd threshold = if(arraySize(cpu) &amp;gt;= 5,cpu[4], else: 0)
    | fieldsAdd threshold = if(arraySize(cpu) &amp;lt; 5 AND arraySize(cpu) &amp;gt; 0, cpu[-1], else: threshold )
    | fields dt.entity.host, threshold
  ], sourceField:dt.entity.host, lookupField:dt.entity.host
], sourceField:id, lookupField:dt.entity.process_group_instance
| filterOut isNull(lookup.dt.entity.host)
| filter arrayAvg(lookup.cpuUsage) &amp;gt;= lookup.lookup.threshold
| sort lookup.host.name&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Line 8 " | filter startsWith(dt.entity.host, "HOST-A")" needed to be added so that the query can return some results. Otherwise, the query will also return the error of "the lookup table is too large"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, this solution is not scalable.&amp;nbsp; I am still looking for a scalable solution to this.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Jun 2023 19:40:19 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-get-the-top-5-process-of-each-host/m-p/214758#M96</guid>
      <dc:creator>StephenLHChan</dc:creator>
      <dc:date>2023-06-12T19:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: DQL - get the top 5 process of each host</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-get-the-top-5-process-of-each-host/m-p/215135#M97</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/59527"&gt;@StephenLHChan&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding "s&lt;SPAN&gt;eems like the top 5 processes of a host will always be the same for the 2 hours" - this is because in the "from" parameter I have specified "-2h" hours. So changing it to -1h should solve that. But I see in your next query you have already managed to to it with a 1h timeslot.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My query was just looking of the top5 processes of the last 2h. But looking at the table I now understand what you are looking for. For every hour the top5 processes per host - looking back x hours. I am not aware of a way how you would achieve this "only" with DQL and I have also discussed this with colleagues. Maybe you can share what you would like to do with that information?&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Best,&lt;BR /&gt;Sini&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 16:15:40 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-get-the-top-5-process-of-each-host/m-p/215135#M97</guid>
      <dc:creator>sinisa_zubic</dc:creator>
      <dc:date>2023-06-15T16:15:40Z</dc:date>
    </item>
    <item>
      <title>Re: DQL - get the top 5 process of each host</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-get-the-top-5-process-of-each-host/m-p/215138#M98</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/59527"&gt;@StephenLHChan&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you maybe share how many&amp;nbsp;dt.entity.process_group_instance records you have in your environment? I am a bit surprised that you are running there with the lookup into a limitation. I was testing the query in an environment with 90k process group instances - and it was running without any problems.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;BR /&gt;Sini&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 16:20:28 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-get-the-top-5-process-of-each-host/m-p/215138#M98</guid>
      <dc:creator>sinisa_zubic</dc:creator>
      <dc:date>2023-06-15T16:20:28Z</dc:date>
    </item>
    <item>
      <title>Re: DQL - get the top 5 process of each host</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-get-the-top-5-process-of-each-host/m-p/215139#M99</link>
      <description>&lt;P&gt;There are &amp;gt;300k process group instances in the environment.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Stephen&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 16:32:45 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-get-the-top-5-process-of-each-host/m-p/215139#M99</guid>
      <dc:creator>StephenLHChan</dc:creator>
      <dc:date>2023-06-15T16:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: DQL - get the top 5 process of each host</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-get-the-top-5-process-of-each-host/m-p/215141#M100</link>
      <description>&lt;P&gt;It is a capacity planning project.&amp;nbsp; We would like to extract the metrics data from Dynatrace to a designated place to do some reporting.&lt;/P&gt;&lt;P&gt;For other metrics like CPU usage, we use the Metrics API to do that.&lt;/P&gt;&lt;P&gt;But, one of the reports is to get top N process of each host for each hour.&lt;/P&gt;&lt;P&gt;At first, we tried with Metrics API but it also exceeds its limit. So, we switch to DQL and try to get the job done.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2023 16:49:47 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-get-the-top-5-process-of-each-host/m-p/215141#M100</guid>
      <dc:creator>StephenLHChan</dc:creator>
      <dc:date>2023-06-15T16:49:47Z</dc:date>
    </item>
    <item>
      <title>Re: DQL - get the top 5 process of each host</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-get-the-top-5-process-of-each-host/m-p/215211#M101</link>
      <description>&lt;P&gt;Thx for the insights. One way I can achieve this is with Dynatrace workflows. You could create a workflow that calculates the top5 processes for every host and ingest that information back into Dynatrace (e.g. as logs or biz events). The workflow can be scheduled to be executed every hour. Then you would have the data easy accessible with DQL.&lt;/P&gt;
&lt;P&gt;Improvements on the DQL side are in the making, so that you don't have to go that way through workflows. But I can't give you any ETA on that.&lt;/P&gt;
&lt;P&gt;Best,&lt;BR /&gt;SIni&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2023 13:36:13 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-get-the-top-5-process-of-each-host/m-p/215211#M101</guid>
      <dc:creator>sinisa_zubic</dc:creator>
      <dc:date>2023-06-16T13:36:13Z</dc:date>
    </item>
  </channel>
</rss>

