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

 

 

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!

AppDynamics Summer Webinars

This summer, our mighty AppDynamics team is cooking up some delicious content on YouTube Live to satiate your ...

SOCin’ it to you at Splunk University

Splunk University is expanding its instructor-led learning portfolio with dedicated Security tracks at .conf25 ...

Credit Card Data Protection & PCI Compliance with Splunk Edge Processor

Organizations handling credit card transactions know that PCI DSS compliance is both critical and complex. The ...