Splunk Search

Comparing two different sources

Muthu_Vinith
Path Finder

Hi Experts, 

I need to compare server lists from two different csv lookups and create a flag based on the comparison results, 
I have two lookups

  • abc.csv - contains list of servers being monitored in dashboard

  • def.csv -contains list of servers from another source

 

  • I need to identify servers present in both abc.csv and def.csv
  • not found in dashboard (i.e abc.csv)
  • and not found in def.csv

How to compare it and create a flag? Any guidance or example queries would be greatly appreciated.
Thank You

Labels (3)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

You should list and categorise them and then do a summarizing stats.

With a normal event search that could be done without appending but since you have the data in lookups you'd need to add a "lookup identifier field" to the lookup contents in order to avoid the append command. Assuming you don't have it, it's something like this:

| inputlookup abc.csv
| eval source=abc.csv
| table  server source
| append
  [ | inputlookup def.csv
     | eval source=def.csv
     | table server source ]

This wil, give you a set of your servers along with an identifier which lookup each server came from.

Now you can do

| stats values(source) as sources by server

And you'll get a multivalued field sources containing either of the source lookups or both of them sk you can use it to filter the data the way you want.

Alternative approach is to not add string labels but numerical ids (like 1 and 2) and then do sum() unstead of values() - then you'd have a field with value 1, 2 or 3 depending on which lookup the server was originally in.

One caveat to the initial building of the list - it uses the append command which has its limitations for run time (which will not be an issue here) and the number of returned results (which might). If you had the field I mentioned at the beginning identifying the lookup, instead of using the append command you could just use another inputlookup command with an append=t option.

0 Karma
Get Updates on the Splunk Community!

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...

Cloud Monitoring Console - Unlocking Greater Visibility in SVC Usage Reporting

For Splunk Cloud customers, understanding and optimizing Splunk Virtual Compute (SVC) usage and resource ...

Automatic Discovery Part 3: Practical Use Cases

If you’ve enabled Automatic Discovery in your install of the Splunk Distribution of the OpenTelemetry ...