Splunk Search

How to compare two fields from two different index and display results with match or No-match?

rohitnaz007
Loves-to-Learn Lots

I am running 2 different Index and have to compare each value in field 1 from 1st index with the values in field2 from index 2 . & also regex is used for other field value. The display result should show a match or a Non Match against each value.    

   Given Data:

(index=cmi cef_vendor="Imperva Inc." cef_product="WAF" dvc="10.124.1.202" act="None" cs2="*" deviceSeverity=High) OR (index=case_management DeviceProduct=WAF fname IN ("*CMI - WAF*"))

| rex field=fname "(-)(?(\s)(PROD|SFR)+(\s))(-)(?(\s)[\w]+(\s)[\w]+(\s))(?(\d)+(\s))(-)"

| eval m=coalesce(cn1,alert)

| stats values(cn1) as cn1 values(alert) as alert by m

| table cn1 alert m

 

Results should be something like this table:

cn1                  alert             m

453626     453626      Match

453624     453626     No Match

@elrich11 

Labels (3)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

What results do you get from that query?  How do those results differ from the desired results?

The coalesce function does not compare fields.  Use if to do that.

| eval m = if(cn1==alert, "Match", "No Match")
---
If this reply helps you, Karma would be appreciated.
0 Karma

rohitnaz007
Loves-to-Learn Lots

Reply got from that query as below,

 

cn1alertm
 43611014361101
4361645 4361645
 43616454361645
4361738 4361738

 & as per your solution,

| eval m = if(cn1==alert, "Match", "No Match")

gives result as below,

cn1alertm
4369221 No Match
 4369135No Match
 4369135No Match
4369418 No Match

 

@richgalloway @elrich11 

want to Expected result Like this,

cn1alertm
43692214369221Match
43692224369135No Match
43692434369135No Match
4369418 No Match
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 ...