<?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: How to Aggregate (Sum) Success vs Failure Counts Totals per Time Interval in DQL in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/How-to-Aggregate-Sum-Success-vs-Failure-Counts-Totals-per-Time/m-p/287411#M2654</link>
    <description>&lt;P&gt;Replace the "| fieldsAdd time = bin(interval, 1m) " by "| fieldsadd time = timeframe[start]" and try again.&lt;/P&gt;&lt;P&gt;It should works now.&lt;/P&gt;</description>
    <pubDate>Tue, 07 Oct 2025 13:40:25 GMT</pubDate>
    <dc:creator>dannemca</dc:creator>
    <dc:date>2025-10-07T13:40:25Z</dc:date>
    <item>
      <title>How to Aggregate (Sum) Success vs Failure Counts Totals per Time Interval in DQL</title>
      <link>https://community.dynatrace.com/t5/DQL/How-to-Aggregate-Sum-Success-vs-Failure-Counts-Totals-per-Time/m-p/287037#M2636</link>
      <description>&lt;P&gt;We are trying to build a metric to monitor the success vs failure rate of an API over time.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Requirement:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Treat all status codes between 400–599 as Failure&lt;/LI&gt;&lt;LI&gt;Treat all other status codes as Success&lt;/LI&gt;&lt;LI&gt;Display this in a bar/line chart with&lt;STRONG&gt;:&lt;/STRONG&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;X-Axis:&lt;/STRONG&gt; Timeframe&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;Y-Axis:&lt;/STRONG&gt; Count of Success and Failure&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;Created a Custom Metric which Captures Endpoint Name and Client ID used for Dashboard Filtering.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;Issue:&lt;/STRONG&gt;&lt;BR /&gt;Using the below DQL, we are able to generate the data. However, the output splits into multiple Success and Failure counts. For example, within a 5-minute interval, each unique combination of endpoint, client, service, and status is treated as a separate record.&lt;/P&gt;&lt;P&gt;Our expectation is to see only two records per timeframe (Success and Failure totals), but instead we are getting multiple entries.&lt;/P&gt;&lt;P&gt;We attempted to use dedup status to consolidate the records, but this results in loss of data and incorrect counts.&lt;/P&gt;&lt;P&gt;Looking for an alternate approach that allows us to aggregate Success and Failure counts properly and visualize them as a bar/line graph.&lt;/P&gt;&lt;P&gt;"If we try to summarize success and failure, then Line Graph goes unsupported."&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;timeseries {
  value = sum(service.muleapi.response.count)
},
by: {dt.entity.service, http.response.status_code},
filter: {
  in(endpoint.name, array($Endpoint)) AND in(`request_attribute.Client-Id`, array($Client_ID))
}
| lookup [
    data record(service_id = "SERVICE-EXXXFB", api_name = "ABC"),
    record(service_id = "SERVICE-9XXXX448", api_name = "DEF"),
    record(service_id = "SERVICE-FXXXX926", api_name ="XYZ")
  ], sourceField: dt.entity.service, lookupField: service_id
| fieldsAdd API = lookup.api_name
| fieldsRemove lookup.service_id, lookup.api_name
| filter in(API, array($API_Name))
| fieldsAdd status = if(condition: http.response.status_code &amp;gt;= 400 AND http.response.status_code &amp;lt; 600,
   then: "Failure", else: "Success" )
| sort status desc
//| dedup status&lt;/LI-CODE&gt;&lt;P&gt;&lt;STRONG&gt;Screenshots: Line Graph with geometry as bar graph&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Without dedup (with Legend) – multiple Success/Failure bars per timeframe&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Raul_rrr_0-1759204168782.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/30302iD1C0061B9CA8BE49/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Raul_rrr_0-1759204168782.png" alt="Raul_rrr_0-1759204168782.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Without dedup (no Legend) – Graph looks fine visually, but bars still represent multiple records instead of aggregated totals&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Raul_rrr_3-1759204294119.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/30305iD2C53660C565B0EC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Raul_rrr_3-1759204294119.png" alt="Raul_rrr_3-1759204294119.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;With dedup – Inaccurate data as multiple records are dropped&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Raul_rrr_2-1759204257435.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/30304iAD5F729DB1E401D1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Raul_rrr_2-1759204257435.png" alt="Raul_rrr_2-1759204257435.png" /&gt;&lt;/span&gt;&lt;BR /&gt;Please suggest an alternate approach (without dedup) to&amp;nbsp;&amp;nbsp;aggregate Success vs Failure counts per timeframe, so that we only see two entries (Success, Failure) per interval?&lt;/P&gt;</description>
      <pubDate>Tue, 30 Sep 2025 04:01:47 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/How-to-Aggregate-Sum-Success-vs-Failure-Counts-Totals-per-Time/m-p/287037#M2636</guid>
      <dc:creator>Raul_rrr</dc:creator>
      <dc:date>2025-09-30T04:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to Aggregate (Sum) Success vs Failure Counts Totals per Time Interval in DQL</title>
      <link>https://community.dynatrace.com/t5/DQL/How-to-Aggregate-Sum-Success-vs-Failure-Counts-Totals-per-Time/m-p/287071#M2638</link>
      <description>&lt;P&gt;Try to add a |maketimeseries sum(value), by:{status}&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.dynatrace.com/docs/discover-dynatrace/platform/grail/dynatrace-query-language/commands/aggregation-commands#makeTimeseries" target="_blank" rel="noopener"&gt;https://docs.dynatrace.com/docs/discover-dynatrace/platform/grail/dynatrace-query-language/commands/aggregation-commands#makeTimeseries&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Sep 2025 14:08:15 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/How-to-Aggregate-Sum-Success-vs-Failure-Counts-Totals-per-Time/m-p/287071#M2638</guid>
      <dc:creator>dannemca</dc:creator>
      <dc:date>2025-09-30T14:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to Aggregate (Sum) Success vs Failure Counts Totals per Time Interval in DQL</title>
      <link>https://community.dynatrace.com/t5/DQL/How-to-Aggregate-Sum-Success-vs-Failure-Counts-Totals-per-Time/m-p/287385#M2651</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/18264"&gt;@dannemca&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for the suggestion! I tried adding&amp;nbsp; | maketimeseries sum(value), by:{status}, but it’s still not working as expected. I’m getting the following error:&lt;BR /&gt;"Please specify the parameter `time` explicitly, as the implicit default timestamp doesn't exist."&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;timeseries {
  value = sum(service.muleapi.response.count)
},
by: {dt.entity.service, http.response.status_code},
filter: {  dt.entity.service == "SERVICE-A123" OR dt.entity.service == "SERVICE-B123" OR 
dt.entity.service == "SERVICE-C123"}
| fieldsAdd status = if(condition: http.response.status_code &amp;gt;= 400 AND http.response.status_code &amp;lt; 600,
   then: "Failure", else: "Success" )
| maketimeseries sum(value), by:{status}&lt;/LI-CODE&gt;&lt;P&gt;Tried adding a time column and feeding it to makeTimeseries, but it fails: | fieldsAdd time = bin(interval, 1m) then | makeTimeseries sum(value), by:{status}, time: time&lt;/P&gt;&lt;P&gt;Execution returns an INCOMPATIBLE_DATA_TYPES&lt;/P&gt;&lt;P&gt;Any suggestions or example snippets that extract/bucket a timestamp from an interval/timeframe and work with makeTimeseries would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Oct 2025 04:56:07 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/How-to-Aggregate-Sum-Success-vs-Failure-Counts-Totals-per-Time/m-p/287385#M2651</guid>
      <dc:creator>Raul_rrr</dc:creator>
      <dc:date>2025-10-07T04:56:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to Aggregate (Sum) Success vs Failure Counts Totals per Time Interval in DQL</title>
      <link>https://community.dynatrace.com/t5/DQL/How-to-Aggregate-Sum-Success-vs-Failure-Counts-Totals-per-Time/m-p/287411#M2654</link>
      <description>&lt;P&gt;Replace the "| fieldsAdd time = bin(interval, 1m) " by "| fieldsadd time = timeframe[start]" and try again.&lt;/P&gt;&lt;P&gt;It should works now.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Oct 2025 13:40:25 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/How-to-Aggregate-Sum-Success-vs-Failure-Counts-Totals-per-Time/m-p/287411#M2654</guid>
      <dc:creator>dannemca</dc:creator>
      <dc:date>2025-10-07T13:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to Aggregate (Sum) Success vs Failure Counts Totals per Time Interval in DQL</title>
      <link>https://community.dynatrace.com/t5/DQL/How-to-Aggregate-Sum-Success-vs-Failure-Counts-Totals-per-Time/m-p/287487#M2656</link>
      <description>&lt;P&gt;you can aggregate timeseries using this syntax:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| summarize value=sum(value[]), by: {dt.entity.service, status, interval, timeframe}&lt;/LI-CODE&gt;&lt;P&gt;full query based on your exampe above:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;timeseries {
  value = sum(service.muleapi.response.count)
},
by: {dt.entity.service, http.response.status_code},
filter: {  dt.entity.service == "SERVICE-A123" OR dt.entity.service == "SERVICE-B123" OR 
dt.entity.service == "SERVICE-C123"}
| fieldsAdd status = if(condition: http.response.status_code &amp;gt;= 400 AND http.response.status_code &amp;lt; 600,
   then: "Failure", else: "Success" )

| summarize value=sum(value[]), by: {dt.entity.service, status, interval, timeframe}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;of couse if you de not need to have breakdown by service, just ommit it in &lt;STRONG&gt;&lt;EM&gt;by:&lt;/EM&gt;&lt;/STRONG&gt; clause&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| summarize value=sum(value[]), by: {status, interval, timeframe}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Oct 2025 12:47:51 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/How-to-Aggregate-Sum-Success-vs-Failure-Counts-Totals-per-Time/m-p/287487#M2656</guid>
      <dc:creator>krzysztof_hoja</dc:creator>
      <dc:date>2025-10-08T12:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to Aggregate (Sum) Success vs Failure Counts Totals per Time Interval in DQL</title>
      <link>https://community.dynatrace.com/t5/DQL/How-to-Aggregate-Sum-Success-vs-Failure-Counts-Totals-per-Time/m-p/287490#M2657</link>
      <description>&lt;P&gt;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/25373"&gt;@krzysztof_hoja&lt;/a&gt;&amp;nbsp; -&amp;nbsp;| summarize value=sum(value[]), by: {status, interval, timeframe} , worked perfectly. Thank you. Much&amp;nbsp;appreciated!!&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/18264"&gt;@dannemca&lt;/a&gt;&amp;nbsp;- Thank you as well for the makeTimeseries suggestion, it was very helpful.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Oct 2025 13:34:43 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/How-to-Aggregate-Sum-Success-vs-Failure-Counts-Totals-per-Time/m-p/287490#M2657</guid>
      <dc:creator>Raul_rrr</dc:creator>
      <dc:date>2025-10-08T13:34:43Z</dc:date>
    </item>
  </channel>
</rss>

