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!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

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