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!

Building Reliable Asset and Identity Frameworks in Splunk ES

 Accurate asset and identity resolution is the backbone of security operations. Without it, alerts are ...

Cloud Monitoring Console - Unlocking Greater Visibility in SVC Usage Reporting

For Splunk Cloud customers, understanding and optimizing Splunk Virtual Compute (SVC) usage and resource ...

Automatic Discovery Part 3: Practical Use Cases

If you’ve enabled Automatic Discovery in your install of the Splunk Distribution of the OpenTelemetry ...