Splunk Search

How to condition match set tokens on input?

mcaulsc
Path Finder

Hi,
I seem to be having a mental block which maybe someone can help with.

I have an input dropdown which runs a query to populate values in the dropdown, depending on the value selected I want to set two more token. The condition match should be on the first 6 characters of the selected value, so if aaaaaa* set two new tokens and if aaaaab* set a different two. All tokens are then used in panels on the dashboard and should refresh each time the value in the dropdown is changed.

sample xml below that will hopefully give the idea.

<input type="dropdown" token="iptoken" searchWhenChanged="true">
<label>Apply Engine</label>
<fieldForLabel>value</fieldForLabel>
<fieldForValue>value</fieldForValue>
<search>
<query>index=ti-u_* sourcetype=$iptoken$ value=aaaaa** | table value |dedup value |sort value</query>
<earliest>@y</earliest>
<latest>now</latest>
</search>
<<change>
<condition match="$iptoken$==&quot;aaaaaa*&quot;">
<set token="newtoken1">newvalue1</set>
<set token="newtoken2">newvalue2</set>
</condition>
<condition match="$iptoken$==&quot;aaaaab*&quot;">
<set token="newtoken1">newvalue1</set>
<set token="newtoken2">newvalue2</set>
</condition>
</change>
</input>

thanks in advance

Labels (1)
0 Karma
1 Solution

somesoni2
SplunkTrust
SplunkTrust

Give this a try

<input type="dropdown" token="iptoken" searchWhenChanged="true">
      <label>Apply Engine</label>
      <fieldForLabel>value</fieldForLabel>
      <fieldForValue>value</fieldForValue>
      <search>
        <query>index=ti-u_* sourcetype=$iptoken$ value=aaaaa** | table value |dedup value |sort value</query>
        <earliest>@y</earliest>
        <latest>now</latest>
      </search>
      <change>
        <condition match=" like($iptoken$,&quot;aaaaaa%&quot;) ">
          <set token="newtoken1">newvalue11</set>
          <set token="newtoken2">newvalue2</set>
        </condition>
        <condition match=" like($iptoken$,&quot;aaaaab%&quot;) ">
          <set token="newtoken1">newvalue31</set>
          <set token="newtoken2">newvalue4</set>
        </condition>
      </change>

View solution in original post

somesoni2
SplunkTrust
SplunkTrust

Give this a try

<input type="dropdown" token="iptoken" searchWhenChanged="true">
      <label>Apply Engine</label>
      <fieldForLabel>value</fieldForLabel>
      <fieldForValue>value</fieldForValue>
      <search>
        <query>index=ti-u_* sourcetype=$iptoken$ value=aaaaa** | table value |dedup value |sort value</query>
        <earliest>@y</earliest>
        <latest>now</latest>
      </search>
      <change>
        <condition match=" like($iptoken$,&quot;aaaaaa%&quot;) ">
          <set token="newtoken1">newvalue11</set>
          <set token="newtoken2">newvalue2</set>
        </condition>
        <condition match=" like($iptoken$,&quot;aaaaab%&quot;) ">
          <set token="newtoken1">newvalue31</set>
          <set token="newtoken2">newvalue4</set>
        </condition>
      </change>

mcaulsc
Path Finder

Superb, been scratching my head on that one for a couple of hours.

Thanks for the solution.

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...