Splunk Search

How to create a search that provides option for a LIKE and not LIKE option

GaryZ
Path Finder

Is there a way of creating a search where we can have both LIKE and NOT LIKE, based on user selected option?

 

ie. 

if $user_option_tk$ == True:

        | where NOT (error_string LIKE "%$filter_tk$%")

else:

        | where error_string LIKE "%$filter_tk$%"

Labels (4)
0 Karma

PickleRick
SplunkTrust
SplunkTrust

Use the filter token to classify your data (set a synthetic field to either 1 or 0 (or true/false, green/red or whatever you want) and then do a "where" command depending on the option token - match eithee the 0s or 1s of your synthetic field.

0 Karma
Get Updates on the Splunk Community!

Say goodbye to manually analyzing phishing and malware threats with Splunk Attack ...

In today’s evolving threat landscape, we understand you’re constantly bombarded with phishing and malware ...

AppDynamics is now part of Splunk Ideas

Hello Splunkers, We have exciting news for you! AppDynamics has been added to the Splunk Ideas Portal. Which ...

Advanced Splunk Data Management Strategies

Join us on Wednesday, May 14, 2025, at 11 AM PDT / 2 PM EDT for an exclusive Tech Talk that delves into ...