Splunk Search

Want to condition match when a value is a single asterisk

simpkins1958
Contributor

Have tried every combination I can think of. Want to set some tokens in a when the value is a single asterisk.

As an exampl this does not work. The condition is matched for everything but a blank field.

<condition match="match(userSearchToken,&quot;\*&quot;)">
0 Karma

simpkins1958
Contributor

Was able to get it working with this XML:

    </input>
     <input type="text" token="deviceToken" searchWhenChanged="true">
       <label>Device:</label>
       <default>*</default>
       <change>
           <condition match="$value$==&quot;*&quot;">
             <set token="filterDeviceToken"></set>
           </condition>
           <condition>
             <set token="filterDeviceToken">nmds_app_dest_survey.d_name=$value|s$</set>
           </condition> 
       </change>      
     </input>

elliotproebstel
Champion

How about this structure instead:

    <input type="text" token="deviceSearchToken" searchWhenChanged="true">
      <label>Device:</label>
      <default>*</default>
      <change>
        <eval token="filterDeviceToken">if($deviceSearchToken$="*", "ASTERISK", "NOT ASTERISK")</eval>
        <eval token="deviceDrilldownToken">if($deviceSearchToken$="*", "ASTERISK2", "NOT ASTERISK2")</eval>
      </change>
    </input>

You'll need to replace "ASTERISK"/"NOT ASTERISK" with the values you actually want to use there, but I'm confused about what your intentions are for those, as the structure you're using inside the <set> elements above isn't really clear to me.

0 Karma

elliotproebstel
Champion

Here's a full test dashboard that you could use to validate:

<form>
  <label>test_match</label>
  <fieldset submitButton="false">
    <input type="text" token="deviceSearchToken" searchWhenChanged="true">
      <label>Device:</label>
      <default>*</default>
      <change>
        <eval token="filterDeviceToken">if($deviceSearchToken$="*", "ASTERISK", "NOT ASTERISK")</eval>
        <eval token="deviceDrilldownToken">if($deviceSearchToken$="*", "ASTERISK2", "NOT ASTERISK2")</eval>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <table>
        <search>
          <query>| stats count | eval first="$filterDeviceToken$", second="$deviceDrilldownToken$"</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
</form>
0 Karma

Kenshiro70
Path Finder

You might want to consider changing $filterDeviceToken$ to $value$. If prefix or suffix is defined, the full token will include them, whereas the value token will return only what's in the input.

0 Karma

simpkins1958
Contributor

Here is a complete example that is not working. When enter a value that is not a single asterisk the match still executes.

    <input type="text" token="deviceSearchToken" searchWhenChanged="true">
      <label>Device:</label>
      <default>*</default>
        <change>
          <condition match="match(deviceSearchToken, &quot;&#92;*&quot;)">
            <set token="filterDeviceToken"></set>
            <set token="deviceDrilldownToken"></set>
          </condition>
          <condition>
            <set token="filterDeviceToken">nmds_app_dest_survey.d_name=$value|s$</set>
            <set token="deviceDrilldownToken">&amp;form.deviceToken=$value|u$</set>            
          </condition>
        </change>      
    </input>
0 Karma
Get Updates on the Splunk Community!

Index This | Why did the turkey cross the road?

November 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...