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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...