Splunk Search

Is it possible to modify a portion of CSV file in inputlookup?

majilan1
Path Finder

Hi Every one,

Is it possible to modify a portion of CSV file in inputlookup?

Cheers.

Labels (1)
0 Karma
1 Solution

bowesmana
SplunkTrust
SplunkTrust

The eval 'case' statement was meant to be an 'if'. Fixed

View solution in original post

bowesmana
SplunkTrust
SplunkTrust

Are you looking to read the CSV, make some modifications and save it back again? If so, 2 approaches.

The first is to simply input, change as needed and then output, e.g.

| inputlookup your.csv
| eval field_value=if(field_value="I want this field", "change me", field_value)
| outputlookup your.csv

or you can use the lookup editor to manually edit the lookup

https://splunkbase.splunk.com/app/1724/

 

0 Karma

majilan1
Path Finder

Thanks bowesmana,

 

0 Karma

bowesmana
SplunkTrust
SplunkTrust

this should do it

REMEMBER:   if you plan to do this automatically - please make sure you have a backup copy of the original in case you get the SPL wrong first time!!!

 

| inputlookup host_blackout.csv
| eval end_time=if(host IN ("mep1", "mep2", "mep3"), "08/28/2022 11:00", end_time)
| oututlookup host_blackout.csv

 

It sounds like you could also use the eval function 'relative_time()' to calculate the 'end of next week', e.g. like this

 

| inputlookup host_blackout.csv
| eval end_time=if(host IN ("mep1", "mep2", "mep3"), 
            strftime(relative_time(now(), "+2w@w7+11h"), "%m/%d/%Y %H:%M"),
            end_time)
| oututlookup host_blackout.csv

 

which would make it 11am on Sunday in the week following

0 Karma

majilan1
Path Finder

I get error in 'EvalCommand': the expression is malformed. Expected).

0 Karma

bowesmana
SplunkTrust
SplunkTrust

The eval 'case' statement was meant to be an 'if'. Fixed

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 ...