Splunk Search

How to compare a search field value with a field value in a lookup ?

mah
Builder

Hi,

My issue is : 

I have a query which contains a "NetworkIterface" field: eni-12345, eni-6789, ...
I have a lookup which contains the list of network interfaces whose ip are public:
I want to be able to create a request which, by combining the search and the lookup, only shows the network interface whose ip are public only.

I have a lookup like that :

ENIPublic IP
eni-1234192.10.10.10
eni-5678192.10.10.11
eni-9012192.10.10.12

 

My search is basic : 

Index=abc sourcetype=xyz NetworkInterface=* 

Thanks for your help !

0 Karma
1 Solution

rnowitzki
Builder

Hi @mah ,

This should work:

| makeresults 
| eval ENI = "eni-1234 eni-9012 eni-9013 eni-9015" 
| makemv ENI
| mvexpand ENI

| lookup pubip.csv "ENI"  OUTPUT "Public IP" as IP
| where IP!=""



You only need the lines starting with the lookup command. The ones above that are just to create some sample data.

Sidenote: I recommend to output your "Public IP" field as "IP" (or maybe "PublicIP"), because spaces in field names cause issues. I could not get the "where" command to work correct with "Public IP" as fieldname...

Hope it helps.

BR
Ralph
--
Karma and/or Solution tagging appreciated.

--
Karma and/or Solution tagging appreciated.

View solution in original post

rnowitzki
Builder

Hi @mah ,

This should work:

| makeresults 
| eval ENI = "eni-1234 eni-9012 eni-9013 eni-9015" 
| makemv ENI
| mvexpand ENI

| lookup pubip.csv "ENI"  OUTPUT "Public IP" as IP
| where IP!=""



You only need the lines starting with the lookup command. The ones above that are just to create some sample data.

Sidenote: I recommend to output your "Public IP" field as "IP" (or maybe "PublicIP"), because spaces in field names cause issues. I could not get the "where" command to work correct with "Public IP" as fieldname...

Hope it helps.

BR
Ralph
--
Karma and/or Solution tagging appreciated.

--
Karma and/or Solution tagging appreciated.
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...