Splunk Search

Update Lookup csv by Splunk Output

RahulMisra1
Explorer

How i update the test_MID_IP.csv  with the output IP, so that next time it runs with updated list

index=abc IP!="10.*" [| inputlookup ip_tracking.csv 
| rename test_DATA AS MID | format ]
| lookup test_MID_IP.csv test_IP as IP OUTPUT test_IP
| eval match=if('IP'== test_IP, "yes", "no")
| search match=no
| stats count by IP
Labels (1)
0 Karma
1 Solution

yuanliu
SplunkTrust
SplunkTrust

I think the OP's test_MID_IP.csv contains test_IP, not IP. (Although it doesn't need to be.)  It doesn't need count but may (or may not) need MID.  Also,  the append option is needed for the table preserve all data.

index=abc IP!="10.*" 
[| inputlookup ip_tracking.csv | rename test_DATA AS MID | format ] 
| lookup test_MID_IP.csv test_IP as IP OUTPUT test_IP 
| where isnull(test_IP)
| dedup IP
| rename IP as test_IP
| fields test_IP MID ``` omit MID if that's not needed ```
| outputlookup append=true test_MID_IP.csv

 

View solution in original post

RahulMisra1
Explorer

Thanks. I want to append the IP to the existing lookup 

test_MID_IP.csv
0 Karma

inventsekar
SplunkTrust
SplunkTrust

Hi @RahulMisra1 

the outputlookup command is used to write the lookup file (we can overwrite or append the lookup file)

Pls note - this one overwrites the lookup file..  if you want to append, pls let us know.. 

index=abc IP!="10.*" 
[| inputlookup ip_tracking.csv | rename test_DATA AS MID | format ] 
| lookup test_MID_IP.csv test_IP as IP OUTPUT test_IP 
| eval match=if('IP'== test_IP, "yes", "no")
| search match=no 
| stats count by IP
| outputlookup test_MID_IP.csv

 

thanks and best regards,
Sekar

PS - If this or any post helped you in any way, pls consider upvoting, thanks for reading !
0 Karma

yuanliu
SplunkTrust
SplunkTrust

I think the OP's test_MID_IP.csv contains test_IP, not IP. (Although it doesn't need to be.)  It doesn't need count but may (or may not) need MID.  Also,  the append option is needed for the table preserve all data.

index=abc IP!="10.*" 
[| inputlookup ip_tracking.csv | rename test_DATA AS MID | format ] 
| lookup test_MID_IP.csv test_IP as IP OUTPUT test_IP 
| where isnull(test_IP)
| dedup IP
| rename IP as test_IP
| fields test_IP MID ``` omit MID if that's not needed ```
| outputlookup append=true test_MID_IP.csv

 

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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

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