Dashboards & Visualizations

How to have search results filtered by checkbox (token) value?

cocomaster
Explorer

I have a token:

[x] Show NACK

When enabled (checked) i want to show entries that have State=NACK
When disabled i want to show entries that have State!=NACK

How can i do it?

Thanks in advance!

Tags (2)
0 Karma
1 Solution

niketn
Legend

@cocomaster since your check box input has only one value you can use the <change> event handler for the checkbox. Based on the details provided check out the following run anywhere example which sets tokShowHideNACK token on checkbox change event handler which can be used in your actual search to filter results as per your need.

<form>
  <label>Check Box Change Event</label>
  <fieldset submitButton="false"></fieldset>
  <row>
    <panel>
      <input type="checkbox" token="tokChkBoxNACK" searchWhenChanged="true">
        <label></label>
        <choice value="show">Show NACK</choice>
        <change>
          <condition label="Show NACK">
            <set token="tokShowHideNACK">State=NACK</set>
          </condition>
          <condition>
            <set token="tokShowHideNACK">State!=NACK</set>
          </condition>
        </change>
      </input>
      <html>
        <div>
          tokShowHideNACK: $tokShowHideNACK$
        </div>
      </html>
    </panel>
  </row>
</form>

Please try out and confirm!

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

niketn
Legend

@cocomaster since your check box input has only one value you can use the <change> event handler for the checkbox. Based on the details provided check out the following run anywhere example which sets tokShowHideNACK token on checkbox change event handler which can be used in your actual search to filter results as per your need.

<form>
  <label>Check Box Change Event</label>
  <fieldset submitButton="false"></fieldset>
  <row>
    <panel>
      <input type="checkbox" token="tokChkBoxNACK" searchWhenChanged="true">
        <label></label>
        <choice value="show">Show NACK</choice>
        <change>
          <condition label="Show NACK">
            <set token="tokShowHideNACK">State=NACK</set>
          </condition>
          <condition>
            <set token="tokShowHideNACK">State!=NACK</set>
          </condition>
        </change>
      </input>
      <html>
        <div>
          tokShowHideNACK: $tokShowHideNACK$
        </div>
      </html>
    </panel>
  </row>
</form>

Please try out and confirm!

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
Get Updates on the Splunk Community!

.conf25 technical session recap of Observability for Gen AI: Monitoring LLM ...

If you’re unfamiliar, .conf is Splunk’s premier event where the Splunk community, customers, partners, and ...

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...

Announcing the Migration of the Splunk Add-on for Microsoft Azure Inputs to ...

Announcing the Migration of the Splunk Add-on for Microsoft Azure Inputs to Officially Supported Splunk ...