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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...