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!

Archived Metrics Now Available for APAC and EMEA realms

We’re excited to announce the launch of Archived Metrics in Splunk Infrastructure Monitoring for our customers ...

Detecting Remote Code Executions With the Splunk Threat Research Team

WATCH NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If exploited, ...

Enter the Dashboard Challenge and Watch the .conf24 Global Broadcast!

The Splunk Community Dashboard Challenge is still happening, and it's not too late to enter for the week of ...