Splunk Search

How to lookup in Splunk?

SharmaS2
Explorer

Hi Team,

i have one abc.csv file with  only one colunm as Source_IP where values are in10.10.10.0/24 format .

next i have  index=xyz which has multiple column as dst,city,counrty , src is one of the  column .

here i need all data from index=xyz where Source_IP from abc.csv matches with src column of index=xyz.

i have uploaded the file successfully but unable to find the relevant query to fetch data ..

 

 

Labels (1)
Tags (1)
0 Karma
1 Solution

Stefanie
Builder

Try something like this:

index=xyz [|inputlookup abc.csv |rename "Source_IP" as "src"|return 999 "src"] 

After the search, add a pipe (|) and the rest of your search criteria. 

View solution in original post

0 Karma

SanjayReddy
SplunkTrust
SplunkTrust

Hi @SharmaS2 

Can you try this 

index=xyz
| lookup abc.csv Source_IP as src  
| table src,dst,city,counrty

OR 

index=xyz
| join type=left src
[| lookup abc.csv Source_IP as src
| fields src]

| table src,dst,city,counrty

0 Karma

Stefanie
Builder

Try something like this:

index=xyz [|inputlookup abc.csv |rename "Source_IP" as "src"|return 999 "src"] 

After the search, add a pipe (|) and the rest of your search criteria. 

0 Karma

SharmaS2
Explorer

thanks ..its working properly ..

 

can you please explain what is 

return 999
Tags (1)
0 Karma

Stefanie
Builder

Sure!

The return command returns values from the subsearch (The stuff in your brackets) so that you can use it to compare with your main search. But the return command automatically limits the number of items returned, you have to tell it how many to return. 
Because I don't know how big your csv is, 999 was a safe bet. 🙂

0 Karma
Get Updates on the Splunk Community!

.conf25 Community Recap

Hello Splunkers, And just like that, .conf25 is in the books! What an incredible few days — full of learning, ...

Splunk App Developers | .conf25 Recap & What’s Next

If you stopped by the Builder Bar at .conf25 this year, thank you! The retro tech beer garden vibes were ...

Congratulations to the 2025-2026 SplunkTrust!

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