<?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 for cumulative percentage of time in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/DQL-for-cumulative-percentage-of-time/m-p/297090#M3242</link>
    <description>&lt;P&gt;Hi team!&lt;/P&gt;&lt;P&gt;I have the following query:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;fetch spans
| filter matchesValue(dt.system.bucket, "obs-educamosclm_spans")
| fieldsAdd duration = toDuration(end_time-start_time), request.is_failed
| fieldsAdd failed = if(request.is_failed, 1, else: 0), dt.kubernetes.workload.name
| fieldsAdd span.timing.cpu, http.response.status_code
| fieldsAdd errors5xx = if(http.response.status_code&amp;gt;=500 and http.response.status_code &amp;lt;600, 1, else: 0)
| fieldsAdd errors4xx = if(http.response.status_code&amp;gt;=400 and http.response.status_code &amp;lt;500, 1, else: 0)
| summarize requestCount = count(), sumTime = sum(duration), meanTime = avg(duration), maxTime = max(duration), standardDeviation = toDuration(stddev(toLong(duration))), meanCPUTime = avg(span.timing.cpu), failed = sum(failed), errors5xx = sum(errors5xx), errors4xx = sum(errors4xx), failureRate = (sum(failed)/count())*100, by:{dt.kubernetes.workload.name, endpoint.name, code.function}
| sort dt.kubernetes.workload.name desc&lt;/LI-CODE&gt;&lt;P&gt;And I would like to add a column with the percentage of sumTime per workfload. Basically, adding the sumTime for the whole workload and calculate the percentage of time that each endpoint takes divided by the total time per workload. However, I want to keep the rest of the fields as well. Is this possible to do?&lt;BR /&gt;Thanks in advance!&lt;/P&gt;</description>
    <pubDate>Wed, 01 Apr 2026 09:02:45 GMT</pubDate>
    <dc:creator>elenaperez</dc:creator>
    <dc:date>2026-04-01T09:02:45Z</dc:date>
    <item>
      <title>DQL for cumulative percentage of time</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-for-cumulative-percentage-of-time/m-p/297090#M3242</link>
      <description>&lt;P&gt;Hi team!&lt;/P&gt;&lt;P&gt;I have the following query:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;fetch spans
| filter matchesValue(dt.system.bucket, "obs-educamosclm_spans")
| fieldsAdd duration = toDuration(end_time-start_time), request.is_failed
| fieldsAdd failed = if(request.is_failed, 1, else: 0), dt.kubernetes.workload.name
| fieldsAdd span.timing.cpu, http.response.status_code
| fieldsAdd errors5xx = if(http.response.status_code&amp;gt;=500 and http.response.status_code &amp;lt;600, 1, else: 0)
| fieldsAdd errors4xx = if(http.response.status_code&amp;gt;=400 and http.response.status_code &amp;lt;500, 1, else: 0)
| summarize requestCount = count(), sumTime = sum(duration), meanTime = avg(duration), maxTime = max(duration), standardDeviation = toDuration(stddev(toLong(duration))), meanCPUTime = avg(span.timing.cpu), failed = sum(failed), errors5xx = sum(errors5xx), errors4xx = sum(errors4xx), failureRate = (sum(failed)/count())*100, by:{dt.kubernetes.workload.name, endpoint.name, code.function}
| sort dt.kubernetes.workload.name desc&lt;/LI-CODE&gt;&lt;P&gt;And I would like to add a column with the percentage of sumTime per workfload. Basically, adding the sumTime for the whole workload and calculate the percentage of time that each endpoint takes divided by the total time per workload. However, I want to keep the rest of the fields as well. Is this possible to do?&lt;BR /&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Wed, 01 Apr 2026 09:02:45 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-for-cumulative-percentage-of-time/m-p/297090#M3242</guid>
      <dc:creator>elenaperez</dc:creator>
      <dc:date>2026-04-01T09:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: DQL for cumulative percentage of time</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-for-cumulative-percentage-of-time/m-p/297099#M3243</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/58054"&gt;@elenaperez&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;You can achieve this by using a lookup to bring in the total &lt;STRONG&gt;sumTime&lt;/STRONG&gt; per workload, and then calculate the percentage for each endpoint from that total.&lt;/P&gt;&lt;P&gt;This may not be the most optimized approach, since it reads spans twice, but it worked fine from my side and keeps all the original fields while adding the percentage column.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;fetch spans
| filter matchesValue(dt.system.bucket, "obs-educamosclm_spans")
| fieldsAdd duration = toDuration(end_time - start_time)
| fieldsAdd workloadName = dt.kubernetes.workload.name
| fieldsAdd failed = if(request.is_failed, 1, else: 0)
| fieldsAdd errors5xx = if(http.response.status_code &amp;gt;= 500 and http.response.status_code &amp;lt; 600, 1, else: 0)
| fieldsAdd errors4xx = if(http.response.status_code &amp;gt;= 400 and http.response.status_code &amp;lt; 500, 1, else: 0)
| summarize
    requestCount = count(),
    sumTime = sum(duration),
    meanTime = avg(duration),
    maxTime = max(duration),
    standardDeviation = toDuration(stddev(toLong(duration))),
    meanCPUTime = avg(span.timing.cpu),
    failed = sum(failed),
    errors5xx = sum(errors5xx),
    errors4xx = sum(errors4xx),
    failureRate = (sum(failed) / count()) * 100,
    by: { workloadName, endpoint.name, code.function }
| lookup [
    fetch spans
    | filter matchesValue(dt.system.bucket, "obs-educamosclm_spans")
    | fieldsAdd duration = toDuration(end_time - start_time)
    | fieldsAdd workloadName = dt.kubernetes.workload.name
    | summarize workloadSumTime = sum(duration), by: { workloadName }
  ],
  sourceField: workloadName,
  lookupField: workloadName,
  fields: { workloadSumTime }
| fieldsAdd sumTimePctPerWorkload = if(
    isNull(workloadSumTime) or toLong(workloadSumTime) == 0,
    null,
    else: round((toLong(sumTime) * 100.0) / toLong(workloadSumTime), decimals: 2)
  )
| fieldsRemove workloadSumTime
| sort workloadName desc&lt;/LI-CODE&gt;&lt;P&gt;I hope it helped&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Apr 2026 10:39:31 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-for-cumulative-percentage-of-time/m-p/297099#M3243</guid>
      <dc:creator>MaximilianoML</dc:creator>
      <dc:date>2026-04-01T10:39:31Z</dc:date>
    </item>
    <item>
      <title>Re: DQL for cumulative percentage of time</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-for-cumulative-percentage-of-time/m-p/297100#M3244</link>
      <description>&lt;P&gt;That worked! Thank you so much&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Apr 2026 10:44:18 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-for-cumulative-percentage-of-time/m-p/297100#M3244</guid>
      <dc:creator>elenaperez</dc:creator>
      <dc:date>2026-04-01T10:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: DQL for cumulative percentage of time</title>
      <link>https://community.dynatrace.com/t5/DQL/DQL-for-cumulative-percentage-of-time/m-p/297103#M3245</link>
      <description>&lt;P&gt;Nice to know, it was my pleasure to help &lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Apr 2026 10:51:59 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQL-for-cumulative-percentage-of-time/m-p/297103#M3245</guid>
      <dc:creator>MaximilianoML</dc:creator>
      <dc:date>2026-04-01T10:51:59Z</dc:date>
    </item>
  </channel>
</rss>

