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 ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...

Updated Data Management and AWS GDI Inventory in Splunk Observability

We’re making some changes to Data Management and Infrastructure Inventory for AWS. The Data Management page, ...