<?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: Metric Timeseries with Array Dimension in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Metric-Timeseries-with-Array-Dimension/m-p/260678#M1371</link>
    <description>&lt;P&gt;This is exactly what I wanted. Thanks so much for the help!&lt;/P&gt;</description>
    <pubDate>Fri, 25 Oct 2024 15:16:05 GMT</pubDate>
    <dc:creator>StrangerThing</dc:creator>
    <dc:date>2024-10-25T15:16:05Z</dc:date>
    <item>
      <title>Metric Timeseries with Array Dimension</title>
      <link>https://community.dynatrace.com/t5/DQL/Metric-Timeseries-with-Array-Dimension/m-p/260543#M1364</link>
      <description>&lt;P&gt;I have a log metric that has a dimension of the array type. When I put this metric in a timeseries, I split by this dimension, however it collects the entire array when doing so, instead of each element. I tried using the expand command and then summarize to do some counting on the elements, but in doing so I lose my timeseries data. When I try to put this back in a timeseries with the makeTimeseries command, I get an error about the time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know I can do what I want by querying the raw logs and using makeTimeseries, which was my workaround for this. But what I'd like to know (mostly because I'm curious) is if there's a way to do what I'm talking about and I just couldn't figure it out. Here's the queries below.&lt;/P&gt;&lt;P&gt;Metric query that I'd like to get a timeseries of each element:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;timeseries sum(log.metric), by:{dimension}
| expand dimension
| summarize count(), by:{dimension}&lt;/LI-CODE&gt;&lt;P&gt;Log query I've used as a workaround:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;fetch logs
| filter dt.system.bucket == "my_bucket"
| filter isNotNull(dimension)
| expand dimension
| makeTimeseries count(), by:{dimension}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2024 13:43:22 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Metric-Timeseries-with-Array-Dimension/m-p/260543#M1364</guid>
      <dc:creator>StrangerThing</dc:creator>
      <dc:date>2024-10-24T13:43:22Z</dc:date>
    </item>
    <item>
      <title>Re: Metric Timeseries with Array Dimension</title>
      <link>https://community.dynatrace.com/t5/DQL/Metric-Timeseries-with-Array-Dimension/m-p/260581#M1366</link>
      <description>&lt;P&gt;When you do this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| summarize count(), by:{dimension}&lt;/LI-CODE&gt;&lt;P&gt;the only fields which survive directly such operation are the ones listed in &lt;EM&gt;&lt;STRONG&gt;by:&lt;/STRONG&gt;&lt;/EM&gt; parameter and these created by expressions listed after &lt;EM&gt;&lt;STRONG&gt;summarize&lt;/STRONG&gt;&lt;/EM&gt;. So there is no possibility to put anything back.&lt;BR /&gt;&lt;BR /&gt;I prepared some example data which create timeseries resembling what you have :&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;data 
  record(timestamp=now(), v=1, dimension=array("a","b")),
  record(timestamp=now()-1m, v=2, dimension=array("a","b")),
  
  record(timestamp=now(), v=3, dimension=array("b")),  
  record(timestamp=now()-1m, v=1, dimension=array("b")),
  
  record(timestamp=now(), v=4, dimension=array("c")),  
  record(timestamp=now()-1m, v=2, dimension=array("c")),
  record(timestamp=now()-2m, v=2, dimension=array("c")),

  record(timestamp=now(), v=1, dimension=array("c","b")),
  record(timestamp=now()-1m, v=2, dimension=array("c","b")),
  record(timestamp=now()-2m, v=2, dimension=array("c","b"))

| makeTimeseries {log.metric=sum(v)}, by:{dimension}, from: now()-5m, interval: 1m&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="krzysztof_hoja_2-1729800062796.png" style="width: 830px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/24126i51C66899DE737FA2/image-dimensions/830x206?v=v2" width="830" height="206" role="button" title="krzysztof_hoja_2-1729800062796.png" alt="krzysztof_hoja_2-1729800062796.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;As I understand the goal is to count over time how many times each element of array being dimension was present in data. This query is calculating this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;data 
  record(timestamp=now(), v=1, dimension=array("a","b")),
  record(timestamp=now()-1m, v=2, dimension=array("a","b")),
  
  record(timestamp=now(), v=3, dimension=array("b")),  
  record(timestamp=now()-1m, v=1, dimension=array("b")),
  
  record(timestamp=now(), v=4, dimension=array("c")),  
  record(timestamp=now()-1m, v=2, dimension=array("c")),
  record(timestamp=now()-2m, v=2, dimension=array("c")),

  record(timestamp=now(), v=1, dimension=array("c","b")),
  record(timestamp=now()-1m, v=2, dimension=array("c","b")),
  record(timestamp=now()-2m, v=2, dimension=array("c","b"))

| makeTimeseries {log.metric=sum(v), timestamp=start()}, by:{dimension}, from: now()-5m, interval: 1m

| expand dimension
| fieldsAdd d=record(timestamp=timestamp[], log.metric=log.metric[])
| expand d
| filterOut isNull(d[log.metric])

| makeTimeseries count(), by: {dimension}, time:d[timestamp], from:now()-5m, interval: 1m&lt;/LI-CODE&gt;&lt;P&gt;In order to have time we need to use &lt;EM&gt;&lt;STRONG&gt;start()&lt;/STRONG&gt;&lt;/EM&gt; function which creates timeseries with timestamps and associate each datapoint with timestamp. I assumed that you do not want to count when metric value was null (data not present)&lt;/P&gt;&lt;P&gt;Result looks like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="krzysztof_hoja_3-1729800364505.png" style="width: 842px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/24127i1E03C0DFC18D035B/image-dimensions/842x202?v=v2" width="842" height="202" role="button" title="krzysztof_hoja_3-1729800364505.png" alt="krzysztof_hoja_3-1729800364505.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I hope it helps&lt;/P&gt;&lt;P&gt;Kris&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2024 20:07:53 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Metric-Timeseries-with-Array-Dimension/m-p/260581#M1366</guid>
      <dc:creator>krzysztof_hoja</dc:creator>
      <dc:date>2024-10-24T20:07:53Z</dc:date>
    </item>
    <item>
      <title>Re: Metric Timeseries with Array Dimension</title>
      <link>https://community.dynatrace.com/t5/DQL/Metric-Timeseries-with-Array-Dimension/m-p/260678#M1371</link>
      <description>&lt;P&gt;This is exactly what I wanted. Thanks so much for the help!&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2024 15:16:05 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Metric-Timeseries-with-Array-Dimension/m-p/260678#M1371</guid>
      <dc:creator>StrangerThing</dc:creator>
      <dc:date>2024-10-25T15:16:05Z</dc:date>
    </item>
  </channel>
</rss>

