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

Get Updates on the Splunk Community!

October Community Champions: A Shoutout to Our Contributors!

As October comes to a close, we want to take a moment to celebrate the people who make the Splunk Community ...

Community Content Calendar, November Edition

Welcome to the November edition of our Community Spotlight! Each month, we dive into the Splunk Community to ...

Stay Connected: Your Guide to November Tech Talks, Office Hours, and Webinars!

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...