Dashboards & Visualizations

Why is my very simple dashboard token condition not working?

gabriel_vasseur
Contributor

I can't seem to set/unset a token based on whether some search result is equal or not to 1.

Can anybody point out why this doesn't work:

<form>
  <label>TEMP Endpoint Processes Clone</label>
  <fieldset submitButton="true" autoRun="false">
    <input type="text" token="number" searchWhenChanged="false">
      <label>Host count</label>
      <default>100</default>
      <initialValue>100</initialValue>
    </input>
  </fieldset>
  <row>
    <panel>
      <html>
      <p>host_count=$host_count$</p>
      <p>host_count1 is 1=$host_count1$</p>
      <p>host_count2 catchall=$host_count2$</p>
      <p>gotuniquehost=$gotuniquehost$</p>
    </html>
    </panel>
  </row>
  <row>
    <panel>
      <table>
        <search>
          <done>
            <condition match="$result.host_count$ == 1">
              <set token="gotuniquehost">True</set>
              <set token="host_count">$result.host_count$</set>
              <set token="host_count1">$result.host_count$</set>
            </condition>
            <condition>
              <unset token="gotuniquehost"></unset>
              <set token="host_count">$result.host_count$</set>
              <set token="host_count2">$result.host_count$</set>
            </condition>
          </done>
          <query>|stats count as host_count | eval host_count=$number$</query>
          <earliest>$earliest$</earliest>
          <latest>$latest$</latest>
        </search>
        <option name="drilldown">none</option>
        <option name="refresh.display">progressbar</option>
      </table>
    </panel>
  </row>
</form>

And yet this is working:

<form>
  <label>TEMP Endpoint Processes Clone</label>
  <fieldset submitButton="true" autoRun="false">
    <input type="text" token="number" searchWhenChanged="false">
      <label>Host count</label>
      <default>100</default>
      <initialValue>100</initialValue>
    </input>
  </fieldset>
  <row>
    <panel>
      <html>
      <p>host_count=$host_count$</p>
      <p>host_count1 gt 1=$host_count1$</p>
      <p>host_count2 lt 1=$host_count2$</p>
      <p>host_count3 catchall=$host_count2$</p>
      <p>gotuniquehost=$gotuniquehost$</p>
    </html>
    </panel>
  </row>
  <row>
    <panel>
      <table>
        <search>
          <done>
            <condition match="$result.host_count$ &gt; 1">
              <unset token="gotuniquehost"></unset>
              <set token="host_count">$result.host_count$</set>
              <set token="host_count1">$result.host_count$</set>
            </condition>
            <condition match="$result.host_count$ &lt; 1">
              <unset token="gotuniquehost"></unset>
              <set token="host_count">$result.host_count$</set>
              <set token="host_count2">$result.host_count$</set>
            </condition>
            <condition>
              <set token="gotuniquehost">True</set>
              <set token="host_count">$result.host_count$</set>
              <set token="host_count3">$result.host_count$</set>
            </condition>
          </done>
          <query>|stats count as host_count | eval host_count=$number$</query>
          <earliest>$earliest$</earliest>
          <latest>$latest$</latest>
        </search>
        <option name="drilldown">none</option>
        <option name="refresh.display">progressbar</option>
      </table>
    </panel>
  </row>
</form>

I run splunk enterprise 7.3.3. This seems to be a bug.

0 Karma
1 Solution

vnravikumar
Champion

Hi

Check this condition <condition match="$result.host_count$ == &quot;1&quot;"> it seems you are getting result.host_count as string.

View solution in original post

vnravikumar
Champion

Hi

Check this condition <condition match="$result.host_count$ == &quot;1&quot;"> it seems you are getting result.host_count as string.

gabriel_vasseur
Contributor

Thanks, that works!

0 Karma
Get Updates on the Splunk Community!

Index This | When is October more than just the tenth month?

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

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What’s New & Next in Splunk SOAR

 Security teams today are dealing with more alerts, more tools, and more pressure than ever.  Join us for an ...