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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

A Four-Part Event Series: Full Stack Observability For the AI Era

As AI reshapes applications, infrastructure, and the way teams operate, the traditional boundaries of ...

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Event Series: Level up your SOC: Advancing with Splunk Enterprise Security

AI has fundamentally raised the stakes for security operations, and this three-part series is your guide to ...