Splunk Search

Compare 2 fields with differents queries

graziaedu
Explorer

I have the follow situation:

queryA returns correlations
AAA
BBB
CCC
DDD

queryB returns correlations 
AAA
CCC
EEE

Expect result is the queryA events with correlations AAA and CCC.

i need a query that compare the field correlation between them and if are equals show me the queryA events.

Thanks

0 Karma

bowesmana
SplunkTrust
SplunkTrust

You can also use the technique

(search1) OR (search2)
| stats values(*) as * by correlation_field
| where (condition)

the condition can then be based on your dataset, e.g. if search1 is sourcetype=A and search2 is sourcetype=B, then condition could be

| where mvcount(sourcetype)=2

because the stats values would have collected both sourcetypes to that field - if there is only one satisfying event correlation, then it is not included.

Another condition might be

| where isnotnull(field_from_search1) AND isnotnull(field_from_search2)

which is basically ensuring that a field from the data set 1 and data set 2 exists in the results.

 

 

0 Karma

richgalloway
SplunkTrust
SplunkTrust

It sounds like the set union command will do the job.  See https://docs.splunk.com/Documentation/Splunk/8.2.2/SearchReference/Set

---
If this reply helps you, Karma would be appreciated.
0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Supercharging Windows Security Detection Performance: Introducing Hybrid Field ...

Windows event logs—from Security auditing and Sysmon to PowerShell script blocks—form the operational backbone ...

Ditch the Manual Grind: Building AI Agents with Splunk

Ditch the Manual Grind: Building AI Agents with Splunk Let’s be real: your team’s time is being eaten alive. ...

Cisco Data Fabric from Architecture to Investigation, Better SOC Visibility, and More ...

Splunk Lantern is Splunk’s customer success center that provides practical guidance from Splunk experts on key ...