Splunk Search

Append search term based on condition

pradeepkumarg
Influencer

How can I append a search term based on a condition?

For example -

if fieldA > 1 
I want to append
| search someCriteriaA
else I want to append
| search someOtherCriteriaB

Here fieldA is output of eventstats.. hence the value of the fieldA would be same across the events

Tags (2)
1 Solution

lguinn2
Legend

Why not this

yourbasesearch (fieldA > 1 AND someCriteriaA) OR (fieldA <= 1 AND someOtherCriteriaB)

Oops - just saw the eventstats comment. Then do this

yourbasesearch
| eventstats something to get fieldA
| search (fieldA > 1 AND someCriteriaA) OR (fieldA <= 1 AND someOtherCriteriaB)

View solution in original post

lguinn2
Legend

Why not this

yourbasesearch (fieldA > 1 AND someCriteriaA) OR (fieldA <= 1 AND someOtherCriteriaB)

Oops - just saw the eventstats comment. Then do this

yourbasesearch
| eventstats something to get fieldA
| search (fieldA > 1 AND someCriteriaA) OR (fieldA <= 1 AND someOtherCriteriaB)
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...