XQL Query to Help Create Correlations Rules

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

XQL Query to Help Create Correlations Rules

L0 Member

Hello i'm trying to do query for the specific fields in the datasets, im trying to do regextract to filter out some specific value in the fields then i use alter to move it to the new fields. But the problem is the value of the fields that im trying to query is appear in the different event. Here's the query that i already make:

 

DATASET 1: create dataset named “verdict” to store new field named MID and Verdict

 

dataset = unknown_unknown_raw |
sort desc _raw_log |
filter _raw_log contains "verdict negative" |
alter MID = regextract(_raw_log , "MID\s(\d+)") |
alter Verdict = regextract(_raw_log, "verdict negative") | 
target type = dataset verdict

 

DATASET2: create dataset named “src” to store a new field named source

 

dataset = unknown_unknown_raw |
sort desc _raw_log |
filter _raw_log contains "ICID" and _raw_log contains "From" and _raw_log contains "@" |
alter source = regextract(_raw_log, "From:\s<([^>]+)>") 

 

DATASET3: create dataset named “dst” to store a new field named destination

 

dataset = unknown_unknown_raw |
sort desc _raw_log |
filter _raw_log contains "ICID" and _raw_log contains "To" and _raw_log contains "@" and _raw_log not contains "From" |
alter destination = regextract(_raw_log, "To:\s<([^>]+)>") |
target type = dataset dst

 

Then after making all the fields, i try to query the new dataset which contains the fields i need that i already regex with this command:

 

dataset in (verdict, src, dst) |
filter verdict != null or MID != null or source != null or destination != null

 

But it only return only 2 fields with value, like:
- MID & verdict

- MID & source

- MID & destination

 

It happens because verdict, source and destination are in the different event but they can have same MID. But i want to do correlations for that 4 fields. My main goals to make a correlation rules to correlate verdict, source and destination with same MID.

 

Is there any best practice to solve this?

1 accepted solution

Accepted Solutions

L4 Transporter

Hello @F.Triaji 

 

Thanks for reaching out on LiveCommunity!

This is happening because in your final query the filter is getting checked against individual datasets not a combination of 3. In order to combine datasets you need to use 'join' stage. But it can join two datasets at a time. Below is the reference document for join stage.

https://docs-cortex.paloaltonetworks.com/r/Cortex-XDR/Cortex-XDR-XQL-Language-Reference/Join

 

By the way why are you creating four different datasets since all are made from same dataset.

View solution in original post

2 REPLIES 2

L4 Transporter

Hello @F.Triaji 

 

Thanks for reaching out on LiveCommunity!

This is happening because in your final query the filter is getting checked against individual datasets not a combination of 3. In order to combine datasets you need to use 'join' stage. But it can join two datasets at a time. Below is the reference document for join stage.

https://docs-cortex.paloaltonetworks.com/r/Cortex-XDR/Cortex-XDR-XQL-Language-Reference/Join

 

By the way why are you creating four different datasets since all are made from same dataset.

L0 Member

Hello @nsinghvirk

Thank you for your reply, i already solve this last query with join as you advised. I do the join for the verdict and src dataset then target it to the new dataset, then merge that new dataset with the dst dataset and finally i can make them in 1 row with the same MID. For the refferences this is my last query:

JOIN 1: MID + VERDICT + SOURCE

dataset = verdict | limit 1 | join type = left (dataset = src) as vs (true = true) | sort asc _time  | target type = dataset vs

 

JOIN 2: MID + VERDICT + SOURCE + DESTINATION

dataset = vs | limit 1 | join type = left (dataset = dst) as sd (true = true) | sort asc _time | target type = dataset result

 

QUERY RESULT: Query new dataset named “result” with 4 fields that i desire in 1 row

dataset = result | fields MID, Verdict, source , destination 

  • 1 accepted solution
  • 1189 Views
  • 2 replies
  • 0 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!