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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...