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
Revered Legend

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
Revered Legend

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
Revered Legend

Thanks @aelliott for pointing it out. corrected now.

0 Karma
Get Updates on the Splunk Community!

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

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...