Splunk Search

How to edit my search to return events with an IP that originate from a Country in a lookup file?

wtaylor149
Explorer

I have a search for my IDS / IPS systems feeding Splunk. I want to evaluate all the IDS/IPS events that have triggered and check any of the src_ip or dest_ip that originate from an embargoed country. I have a lookup table with one column called Country. I've tried a few different searches, but none have returned any results. I imagine there must be an eval statement I'm missing somewhere...not sure.

Search:

index=ids_ips [|inputlookup embargoed_countries.csv | fields Country] |dedup src_ip dest_ip|iplocation src_ip|fillnull value=No_Country_Defined Country|table src_ip dest_ip Country
0 Karma
1 Solution

sundareshr
Legend

Maybe this will help
index=ids_ips |dedup src_ip dest_ip |iplocation src_ip|search [|inputlookup embargoed_countries.csv | fields Country] |table src_ip dest_ip Country

View solution in original post

0 Karma

somesoni2
Revered Legend

How do you map the country to a src_ip and/or dest_ip? Do the event sin index=ids_ips have Country field in them?

0 Karma

wtaylor149
Explorer

That's kind of what I'm trying to accomplish. Run a search in the ids_ips index (i add the country with the "iplocation src_ip" command). Evaluate the Country from the search against the csv file looking for matches. Hope that makes sense.
Search returns:
src_ip Country
2.2.2.2 United States (don't show in the results)
5.5.5.5 Somalia (show in the results)

0 Karma

somesoni2
Revered Legend

Then try the answer by @sundareshr. Validate the lookup table name and the name of the country field (it should match with your search result).

0 Karma

sundareshr
Legend

Maybe this will help
index=ids_ips |dedup src_ip dest_ip |iplocation src_ip|search [|inputlookup embargoed_countries.csv | fields Country] |table src_ip dest_ip Country

0 Karma

wtaylor149
Explorer

Not sure what happened but the search worked. Thank you for your help.

0 Karma

wtaylor149
Explorer

Unfortunately this search did not do the trick. It only returned 12 lines and all from the same country. I know I have more than a few embargoed_countries banging on the door.

0 Karma

somesoni2
Revered Legend

Run this and find the count by countries. Then compare the results from above query if that is correct or not

index=ids_ips |dedup src_ip dest_ip |iplocation src_ip | stats count by Country
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, ...