Splunk Search

XML Conditional suffix prefix

weidertc
Communicator

I have an input text and input dropdown that both need to allow blank value.  They cannot be null since the token must be set or the queries that use it won't run.  I need a prefix and suffix both wildcards only when there's a value, and to use a single wildcard (*) in its absence.

I tried this, but the prefix and suffix keep multiplying and soon i have 10 suffixes and 10 prefixes.

here's the input text:

 

      <prefix/>
      <suffix/>
      <change>
        <eval token="assetFilter">if(len($assetFilter$)&gt;0, "*" . $assetFilter$ . "*", "*")</eval>
      </change>

 

after entering, removing, entering, removing values, the suffix and prefix kept multiplying and eventually looked like this

****tag=****

 

Here's the other one, a dropdown of macros so it needs the ` char with the wildcard, after selecting, unselecting, selecting, and unselecting values in the dropdown.

 

        <change>
          <eval token="asset">if(len($asset$)&gt;0, "*`" . $asset$ . "`*", "*")</eval>
        </change>

 

*`*`*`*`*`*`*`*`*`*`*`*`*`*`*`ED_ENDI_Asdf`*`*`*`*`*`*`*`*`*`*`*`*`*`*`*

 

How can I use prefix and suffix conditionally a little better or in a way that works?

-c

 

 

Labels (1)
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Have you tried setting a different token e.g. 

<eval token="assetFilter2">if(len($assetFilter$)&gt;0, "*" . $assetFilter$ . "*", "*")</eval>
0 Karma

weidertc
Communicator

Yea I tried that.  it makes no difference.

I give up on this.  It's taking too much time.

thanks for your help.

0 Karma
Get Updates on the Splunk Community!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...