XQL Help - Count array values

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements

XQL Help - Count array values

L0 Member

Hello,

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

 

Context 

  • I have a BIOC rule monitoring for read on multiple folders that can contains identical files.

Target

  • The list of the top file that have been read

Example 

  • Monitored file path 
    • C:\users\jhon\
    • C:\users\doe\
  • Example file opened
    • C:\users\jhon\test.txt
    • C:\users\doe\test.txt
    • C:\users\doe\also_test.txt

Desired output

File Hits
test.txt 2
also_test.txt 1


My take 

dataset = alerts 
| filter rule_id = "whatever"
| fields file_name
| alter file = arraystring(arraydistinct(file_name),",")
| comp count(file_name) as hits by file


Any suggestions ?

1 accepted solution

Accepted Solutions

L2 Linker

hi @MatthieuFouet 

 

I hope i got the use correctly, and based on my understadning, you may try the below query 


dataset = alerts
| fields rule_id , file_name , file_sha256
| arrayexpand file_name
| comp count(file_name ) as Hits by file_name
| sort desc Hits

Sample output should look like the below 

zarnous_0-1706796223324.png

You may also add more fields, and filters as you wish if you need so!

If this answers your question feel free to mark it as a solution so other can benefit from!

Thanks
Z

Z

View solution in original post

1 REPLY 1

L2 Linker

hi @MatthieuFouet 

 

I hope i got the use correctly, and based on my understadning, you may try the below query 


dataset = alerts
| fields rule_id , file_name , file_sha256
| arrayexpand file_name
| comp count(file_name ) as Hits by file_name
| sort desc Hits

Sample output should look like the below 

zarnous_0-1706796223324.png

You may also add more fields, and filters as you wish if you need so!

If this answers your question feel free to mark it as a solution so other can benefit from!

Thanks
Z

Z
  • 1 accepted solution
  • 1057 Views
  • 1 replies
  • 1 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!