Splunk Search

searchmatch function

surekhasplunk
Communicator

Hi

I am trying to find an ip from first query and then search that ip if exists in another csv file and show the count of only those ips

| inputlookup asset_list.csv 
| search "Infrastrucure Name"="xyz" | eval main_ip=IP [| inputlookup ip_exist.csv  |  eval test=if(searchmatch("IP=$main_ip$"), "yes", "no") | table IP test | where test="yes" ]

But i am getting error in the eval function.
please help.

Tags (3)
0 Karma

renjith_nair
Legend

@surekhasplunk,

Try

 | inputlookup asset_list.csv |eval source="asset"
 | search "Infrastrucure Name"="xyz" |append [| inputlookup ip_exist.csv|eval source="exist" ]
 | stats count,values(source) as source by IP|where mvcount(source) > 1

If you have different field names for IP in the csv, rename one of them
If you have unique IPs in both files, stats ccount by IP|where count >1 also should work

---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma
Get Updates on the Splunk Community!

Community Content Calendar, November Edition

Welcome to the November edition of our Community Spotlight! Each month, we dive into the Splunk Community to ...

October Community Champions: A Shoutout to Our Contributors!

As October comes to a close, we want to take a moment to celebrate the people who make the Splunk Community ...

Stay Connected: Your Guide to November Tech Talks, Office Hours, and Webinars!

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...