<?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 XQL Help - Count array values in Cortex XDR Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/xql-help-count-array-values/m-p/575319#M5997</link>
    <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;XQL beginner here, after 1 hour of tryhard with the cheap xql palo alto documentation. Finally got what I want but I feel like I've done it the wrong wa&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Context&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;I have a BIOC rule monitoring for read on multiple folders that can contains identical files.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Target&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The list of the top file that have been read&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Example&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;EM&gt;Monitored file path&lt;/EM&gt;&amp;nbsp;
&lt;UL&gt;
&lt;LI&gt;C:\users\jhon\&lt;/LI&gt;
&lt;LI&gt;C:\users\doe\&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;&lt;EM&gt;Example file opened&lt;/EM&gt;
&lt;UL&gt;
&lt;LI&gt;C:\users\jhon\test.txt&lt;/LI&gt;
&lt;LI&gt;C:\users\doe\test.txt&lt;/LI&gt;
&lt;LI&gt;C:\users\doe\also_test.txt&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Desired output&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;File&lt;/TD&gt;
&lt;TD width="50%"&gt;Hits&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;test.txt&lt;/TD&gt;
&lt;TD width="50%"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;also_test.txt&lt;/TD&gt;
&lt;TD width="50%"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;My take&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;dataset = alerts 
| filter rule_id = "whatever"
| fields file_name
| alter file = arraystring(arraydistinct(file_name),",")
| comp count(file_name) as hits by file&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;Any suggestions ?&lt;/P&gt;</description>
    <pubDate>Thu, 01 Feb 2024 13:48:18 GMT</pubDate>
    <dc:creator>MatthieuFouet</dc:creator>
    <dc:date>2024-02-01T13:48:18Z</dc:date>
    <item>
      <title>XQL Help - Count array values</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/xql-help-count-array-values/m-p/575319#M5997</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;XQL beginner here, after 1 hour of tryhard with the cheap xql palo alto documentation. Finally got what I want but I feel like I've done it the wrong wa&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Context&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;I have a BIOC rule monitoring for read on multiple folders that can contains identical files.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Target&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;The list of the top file that have been read&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Example&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;EM&gt;Monitored file path&lt;/EM&gt;&amp;nbsp;
&lt;UL&gt;
&lt;LI&gt;C:\users\jhon\&lt;/LI&gt;
&lt;LI&gt;C:\users\doe\&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;&lt;EM&gt;Example file opened&lt;/EM&gt;
&lt;UL&gt;
&lt;LI&gt;C:\users\jhon\test.txt&lt;/LI&gt;
&lt;LI&gt;C:\users\doe\test.txt&lt;/LI&gt;
&lt;LI&gt;C:\users\doe\also_test.txt&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;STRONG&gt;Desired output&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;File&lt;/TD&gt;
&lt;TD width="50%"&gt;Hits&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;test.txt&lt;/TD&gt;
&lt;TD width="50%"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="50%"&gt;also_test.txt&lt;/TD&gt;
&lt;TD width="50%"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;My take&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;dataset = alerts 
| filter rule_id = "whatever"
| fields file_name
| alter file = arraystring(arraydistinct(file_name),",")
| comp count(file_name) as hits by file&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;Any suggestions ?&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2024 13:48:18 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/xql-help-count-array-values/m-p/575319#M5997</guid>
      <dc:creator>MatthieuFouet</dc:creator>
      <dc:date>2024-02-01T13:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: XQL Help - Count array values</title>
      <link>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/xql-help-count-array-values/m-p/575325#M5998</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/317229697"&gt;@MatthieuFouet&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope i got the use correctly, and based on my understadning, you may try the below query&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;dataset = alerts &lt;BR /&gt;| fields rule_id , file_name , file_sha256 &lt;BR /&gt;| arrayexpand file_name &lt;BR /&gt;| comp count(file_name ) as Hits by file_name &lt;BR /&gt;| sort desc Hits&lt;BR /&gt;&lt;BR /&gt;Sample output should look like the below&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="zarnous_0-1706796223324.png" style="width: 400px;"&gt;&lt;img src="https://live.paloaltonetworks.com/t5/image/serverpage/image-id/57029i2DEAF02AB74336B6/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="zarnous_0-1706796223324.png" alt="zarnous_0-1706796223324.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You may also add more fields, and filters as you wish if you need so!&lt;BR /&gt;&lt;BR /&gt;If this answers your question feel free to mark it as a solution so other can benefit from!&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Z&lt;/P&gt;</description>
      <pubDate>Thu, 01 Feb 2024 14:05:25 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/cortex-xdr-discussions/xql-help-count-array-values/m-p/575325#M5998</guid>
      <dc:creator>zarnous</dc:creator>
      <dc:date>2024-02-01T14:05:25Z</dc:date>
    </item>
  </channel>
</rss>

