Splunk Search

Eval a field twice based on index name

bleung93
Path Finder

I have a field totalVolumeGB thats value is based on the eval below. I want to eval the same field, but with a filter based on the index field.

The index field is essentially index=*.

... | eval totalVolumeGB=10*(homePath_maxDataSizeMB+coldPath_maxDataSizeMB)/1024

I want to add this to the previous query, when my "index=summary_*"

... | eval totalVolumeGB=23*(homePath_maxDataSizeMB+coldPath_maxDataSizeMB)/1024

0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

try this

   ... | eval totalVolumeGB=if(like(index,"summary_%"),23*(homePath_maxDataSizeMB+coldPath_maxDataSizeMB)/1024,10*(homePath_maxDataSizeMB+coldPath_maxDataSizeMB)/1024) | ...

OR

... | eval totalVolumeGB =(homePath_maxDataSizeMB+coldPath_maxDataSizeMB)/1024| eval totalVolumeGB=if(like(index,"summary_%"),23*totalVolumeGB ,10*totalVolumeGB ) | ...

View solution in original post

aelliott
Motivator

how about something like this:
... | eval num=if(like(index,"summary_%"),23,10) | eval totalVolumeGB=num*(homePath_maxDataSizeMB+coldPath_maxDataSizeMB)/1024

somesoni2
SplunkTrust
SplunkTrust

try this

   ... | eval totalVolumeGB=if(like(index,"summary_%"),23*(homePath_maxDataSizeMB+coldPath_maxDataSizeMB)/1024,10*(homePath_maxDataSizeMB+coldPath_maxDataSizeMB)/1024) | ...

OR

... | eval totalVolumeGB =(homePath_maxDataSizeMB+coldPath_maxDataSizeMB)/1024| eval totalVolumeGB=if(like(index,"summary_%"),23*totalVolumeGB ,10*totalVolumeGB ) | ...

somesoni2
SplunkTrust
SplunkTrust

Thanks @aelliott for pointing it out. corrected now.

0 Karma
Get Updates on the Splunk Community!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...