Splunk Search

How to compare values in col1 to col2, and return all values existing in col1, but also NOT in col 2?

michael_wong
Path Finder

Here is my situation. I can use subsearch to get two column data, just like below.

Data row is not aligned, so I can't simply use eval if to compare. Some of the value is identical, but some is not. I want to output the value existing in col1, but not exist in col 2

column1 column 2

AA            BB

CC           AA

DD           FF

EE            ZZ

FF            XX

VV          MM

Labels (2)
0 Karma
1 Solution

michael_wong
Path Finder

I've solved it out.

First add a "+" to each column to mark that value is existing in col1 OR col2

And then I can combine the lines using command stats first(*) as * by host.

search 1 | | eval col1="+" | append [ search2 | col2 ="+"]
| stats first(*) as * by HOST
| where isnotnull(col1) AND isnull(col2 )

View solution in original post

0 Karma

michael_wong
Path Finder

I've solved it out.

First add a "+" to each column to mark that value is existing in col1 OR col2

And then I can combine the lines using command stats first(*) as * by host.

search 1 | | eval col1="+" | append [ search2 | col2 ="+"]
| stats first(*) as * by HOST
| where isnotnull(col1) AND isnull(col2 )

0 Karma
Get Updates on the Splunk Community!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI!Discover how Splunk’s agentic AI ...

Splunk Enterprise Security 8.x: The Essential Upgrade for Threat Detection, ...

Watch On Demand the Tech Talk on November 6 at 11AM PT, and empower your SOC to reach new heights! Duration: ...

Splunk Observability as Code: From Zero to Dashboard

For the details on what Self-Service Observability and Observability as Code is, we have some awesome content ...