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!

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...