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 (4)
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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...