Splunk Search

How to find the difference of two query results?

pench2k19
Explorer

Hi team,

I have two queries as follows

query1:

|inputlookup  abc.csv |table file  sla_time

query2:

index=xxx   source=yyyy |table file2

file2 values are subset of file values. I want to print the difference between the file and file2 fields along with the sla_time from the first query.

Can you help me here

@jkat54 @vnravikumar

0 Karma

VatsalJagani
SplunkTrust
SplunkTrust

Hi @pench2k19,
You can use set difference for this purpose. This is similar to set in normal programming language or mathematics so this is even easy to understood. At the end use lookup command to get sla_time field.

| set diff [|inputlookup abc.csv |table file] [index=xxx source=yyyy | rename file2 as file|table file] | lookup abc.csv file output sla_time

Hope this helps!!!

0 Karma

somesoni2
Revered Legend

Give this a try (giving list of file and corresponding sla_time from lookup abc.csv, which doesn't have a matching row in the search)

index=xxx source=yyyy |stats count by file2  | rename file2 as file
| append [|inputlookup abc.csv |table file sla_time]
| stats values(sla_time) as sla_time values(count) as count by file
| where isnull(count) 
0 Karma

pench2k19
Explorer

No luck @somesoni2..

0 Karma
Get Updates on the Splunk Community!

Enterprise Security Content Update (ESCU) | New Releases

In December, the Splunk Threat Research Team had 1 release of new security content via the Enterprise Security ...

Why am I not seeing the finding in Splunk Enterprise Security Analyst Queue?

(This is the first of a series of 2 blogs). Splunk Enterprise Security is a fantastic tool that offers robust ...

Index This | What are the 12 Days of Splunk-mas?

December 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...