<?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 Count of memory usage breaches in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/Count-of-memory-usage-breaches/m-p/236128#M606</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to get my query to return a count of breaches of a threshold for the memory usage on a set of server.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, i'm not quite being able to figure out that's possible. The current query I have returns the max memory usage for the given hosts. How would I go about adding a count() feature to this?&lt;/P&gt;&lt;P&gt;timeseries usage=max(dt.host.memory.usage), by:{host.name}, interval:1h&lt;BR /&gt;| filter host.name == "host1" OR host.name == "host2" OR host.name == "host3" OR host.name == "host4"&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 02 Feb 2024 11:01:56 GMT</pubDate>
    <dc:creator>uzahid</dc:creator>
    <dc:date>2024-02-02T11:01:56Z</dc:date>
    <item>
      <title>Count of memory usage breaches</title>
      <link>https://community.dynatrace.com/t5/DQL/Count-of-memory-usage-breaches/m-p/236128#M606</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to get my query to return a count of breaches of a threshold for the memory usage on a set of server.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, i'm not quite being able to figure out that's possible. The current query I have returns the max memory usage for the given hosts. How would I go about adding a count() feature to this?&lt;/P&gt;&lt;P&gt;timeseries usage=max(dt.host.memory.usage), by:{host.name}, interval:1h&lt;BR /&gt;| filter host.name == "host1" OR host.name == "host2" OR host.name == "host3" OR host.name == "host4"&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 11:01:56 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Count-of-memory-usage-breaches/m-p/236128#M606</guid>
      <dc:creator>uzahid</dc:creator>
      <dc:date>2024-02-02T11:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: Count of memory usage breaches</title>
      <link>https://community.dynatrace.com/t5/DQL/Count-of-memory-usage-breaches/m-p/236187#M610</link>
      <description>&lt;P&gt;You can use iterative expression to compare each value of returned timeseries against threshold and put in breaches table 1 when&amp;nbsp; it is crossed (otherwise 0). By summing elements of breaches table you get count of hours where memory usage was above certain level at least once:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;timeseries usage=max(dt.host.memory.usage, default:0), interval:1h, by:{dt.entity.host}
, filter: { matchesValue(host.name,"*filter*", caseSensitive:false) }
| fieldsAdd breaches= if(usage[]&amp;gt;22,1,else:0)  // my ex. threshold = 22
| fieldsAdd breachesCount=arraySum(breaches)&lt;/LI-CODE&gt;&lt;P&gt;result of this query on my data 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_0-1706910733665.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/17380i988AFCE53D672AB7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="krzysztof_hoja_0-1706910733665.png" alt="krzysztof_hoja_0-1706910733665.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;you can also do the operation in single line using iCollectArray:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| fieldsAdd breachesCount= arraySum(iCollectArray(if(usage[]&amp;gt;22,1,else:0)))&lt;/LI-CODE&gt;&lt;P&gt;Kris&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 22:02:46 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/Count-of-memory-usage-breaches/m-p/236187#M610</guid>
      <dc:creator>krzysztof_hoja</dc:creator>
      <dc:date>2024-02-02T22:02:46Z</dc:date>
    </item>
  </channel>
</rss>

