<?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: DQLQuery for calculating totalbytes sent/received by portfolios in DQL</title>
    <link>https://community.dynatrace.com/t5/DQL/DQLQuery-for-calculating-totalbytes-sent-received-by-portfolios/m-p/233640#M506</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/69601"&gt;@ramsundar&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I hope i can answer your question you should be able to us the "by:" keyword in the summarize if we start off with this data:&lt;/P&gt;&lt;P&gt;data record( sentbyte = 10 , receivedbyte = 20 , subnet = "Retail") ,&lt;BR /&gt;record( sentbyte = 10 , receivedbyte = 20 , subnet = "Retail"),&lt;BR /&gt;record( sentbyte = 10 , receivedbyte = 20 , subnet = "Retail"),&lt;BR /&gt;record( sentbyte = 10 , receivedbyte = 20 , subnet = "HR")&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LukeHearth_1-1704733093690.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/16668i3E6D2178D8661BF7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LukeHearth_1-1704733093690.png" alt="LukeHearth_1-1704733093690.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We can then use this line to add up the bytes to get the sum:&lt;/P&gt;&lt;P&gt;| summarize total = sum(receivedbyte + sentbyte) , by:subnet&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LukeHearth_0-1704733050222.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/16667i250236ABE7983AE4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LukeHearth_0-1704733050222.png" alt="LukeHearth_0-1704733050222.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if this helps.&lt;/P&gt;&lt;P&gt;Yours,&lt;/P&gt;&lt;P&gt;Luke Hearth&lt;/P&gt;</description>
    <pubDate>Mon, 08 Jan 2024 16:58:41 GMT</pubDate>
    <dc:creator>LukeHearth</dc:creator>
    <dc:date>2024-01-08T16:58:41Z</dc:date>
    <item>
      <title>DQLQuery for calculating totalbytes sent/received by portfolios</title>
      <link>https://community.dynatrace.com/t5/DQL/DQLQuery-for-calculating-totalbytes-sent-received-by-portfolios/m-p/231458#M417</link>
      <description>&lt;P&gt;We are forwarding Firewall traffic logs to dynatrace , and we split into columns like srcip , dstip , port , sentbyte &amp;amp; received byte.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now i need calculate totalbytes by adding sent &amp;amp; received byte , which should group based on the subnets&amp;nbsp;&lt;BR /&gt;each subnet is specific to unique team .&amp;nbsp;&lt;BR /&gt;Example :&lt;BR /&gt;&amp;nbsp;Retail - 100GB&lt;BR /&gt;&amp;nbsp;Infra - 100 GB&lt;BR /&gt;&amp;nbsp;HR&amp;nbsp; &amp;nbsp;- 100GB&lt;/P&gt;&lt;P&gt;&amp;nbsp;The query im using is bleow&lt;BR /&gt;fetch logs ,from:now() - 24h //, scanLimitGBytes: 500, samplingRatio: 1000&lt;BR /&gt;| filter matchesPhrase(host, "SDW-") AND ( toIp(srcip)==ipMask("10.0.0.0",24) OR toIP(dstip)==ipMask("10.0.0.0",24) )&lt;BR /&gt;| summarize Totalbytes = sum(toDouble(sentbyte)+toDouble(rcvdbyte))&lt;BR /&gt;&lt;BR /&gt;how case function in DQL ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Dec 2023 13:23:06 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQLQuery-for-calculating-totalbytes-sent-received-by-portfolios/m-p/231458#M417</guid>
      <dc:creator>ramsundar</dc:creator>
      <dc:date>2023-12-11T13:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: DQLQuery for calculating totalbytes sent/received by portfolios</title>
      <link>https://community.dynatrace.com/t5/DQL/DQLQuery-for-calculating-totalbytes-sent-received-by-portfolios/m-p/233640#M506</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.dynatrace.com/t5/user/viewprofilepage/user-id/69601"&gt;@ramsundar&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I hope i can answer your question you should be able to us the "by:" keyword in the summarize if we start off with this data:&lt;/P&gt;&lt;P&gt;data record( sentbyte = 10 , receivedbyte = 20 , subnet = "Retail") ,&lt;BR /&gt;record( sentbyte = 10 , receivedbyte = 20 , subnet = "Retail"),&lt;BR /&gt;record( sentbyte = 10 , receivedbyte = 20 , subnet = "Retail"),&lt;BR /&gt;record( sentbyte = 10 , receivedbyte = 20 , subnet = "HR")&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LukeHearth_1-1704733093690.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/16668i3E6D2178D8661BF7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LukeHearth_1-1704733093690.png" alt="LukeHearth_1-1704733093690.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We can then use this line to add up the bytes to get the sum:&lt;/P&gt;&lt;P&gt;| summarize total = sum(receivedbyte + sentbyte) , by:subnet&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LukeHearth_0-1704733050222.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/16667i250236ABE7983AE4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="LukeHearth_0-1704733050222.png" alt="LukeHearth_0-1704733050222.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if this helps.&lt;/P&gt;&lt;P&gt;Yours,&lt;/P&gt;&lt;P&gt;Luke Hearth&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jan 2024 16:58:41 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQLQuery-for-calculating-totalbytes-sent-received-by-portfolios/m-p/233640#M506</guid>
      <dc:creator>LukeHearth</dc:creator>
      <dc:date>2024-01-08T16:58:41Z</dc:date>
    </item>
    <item>
      <title>Re: DQLQuery for calculating totalbytes sent/received by portfolios</title>
      <link>https://community.dynatrace.com/t5/DQL/DQLQuery-for-calculating-totalbytes-sent-received-by-portfolios/m-p/233954#M531</link>
      <description>&lt;P&gt;1. Case function can be realized as a combination of of &lt;STRONG&gt;&lt;EM&gt;coalesce&lt;/EM&gt; &lt;/STRONG&gt;and &lt;EM&gt;&lt;STRONG&gt;if&lt;/STRONG&gt; &lt;/EM&gt;functions&lt;/P&gt;&lt;P&gt;2. Matching IP addresses to networks can be simplified using &lt;STRONG&gt;&lt;EM&gt;ipIn&lt;/EM&gt; &lt;/STRONG&gt;function (&lt;A href="https://docs.dynatrace.com/docs/platform/grail/dynatrace-query-language/functions/network-functions#ipIn" target="_blank"&gt;https://docs.dynatrace.com/docs/platform/grail/dynatrace-query-language/functions/network-functions#ipIn&lt;/A&gt;)&lt;BR /&gt;3. and &lt;EM&gt;&lt;STRONG&gt;summarize&lt;/STRONG&gt; &lt;/EM&gt;command mentioned by Luke is the final ingredient to produce few values out of many log records&amp;nbsp;&lt;BR /&gt;Using my private, but similar data this could look like:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;fetch logs 
| fieldsAdd team = coalesce(
    if (ipIn(srcaddr, "10.176.1.0/24"), "Retail"),
    if (ipIn(srcaddr, "10.176.2.0/24"), "Infra"),
    if (ipIn(srcaddr, "10.176.3.0/24"), "HR"),
    "Other"
)
| summarize {totalbytes=sum(toLong(bytes))}, by: { team }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&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_1-1704917298573.png" style="width: 400px;"&gt;&lt;img src="https://community.dynatrace.com/t5/image/serverpage/image-id/16733i1F9204256A7EA1BE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="krzysztof_hoja_1-1704917298573.png" alt="krzysztof_hoja_1-1704917298573.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Kris&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 20:09:17 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/DQL/DQLQuery-for-calculating-totalbytes-sent-received-by-portfolios/m-p/233954#M531</guid>
      <dc:creator>krzysztof_hoja</dc:creator>
      <dc:date>2024-01-10T20:09:17Z</dc:date>
    </item>
  </channel>
</rss>

