Splunk Search

Is it possible to put a Checkbox (YES/NO) in order to let the user choose whether or not to apply drop-down input choices (addinput)?

skender27
Contributor

Hi,

I have an addinput drop-down selection which applies to my dashboard (as a token).
Is it possible to put a Checkbox (YES/NO) in order to let the user choose whether or not to apply the drop-down choices?
In the sense that if you choose NO, the choices of the drop-down menu are useless and do not apply to the search string...

Thanks,
Skender

0 Karma

somesoni2
Revered Legend

It depends on how your dropdown selection is used in panel searches. You can have a checkbox with a default value and panel search will have a subsearch to apply dropdown filter based on checkbox value.

A run anywhere sample dashboard is here.

<form>
  <label>ConditionalFilter</label>
  <fieldset submitButton="false">
    <input type="checkbox" searchWhenChanged="true" token="applyFilter">
      <label></label>
      <choice value="1">Apply Filter</choice>
      <default>0</default>
    </input>
    <input type="dropdown" searchWhenChanged="true" token="sourcetype">
      <label>Select Sourcetype</label>
      <choice value="splunkd">splunkd</choice>
      <choice value="scheduler">scheduler</choice>
      <choice value="splunkd_ui_access">splunkd_ui_access</choice>
      <default>splunkd</default>
    </input>
  </fieldset>
  <row>
    <panel>
      <chart>
        <search>
          <query>index=_internal [| gentimes start=-1 | eval sourcetype=if(replace("$applyFilter$",".*(\d)","\1")="1","$sourcetype$","*") | table sourcetype]| timechart  count by sourcetype</query>
          <earliest>-60m@m</earliest>
          <latest>now</latest>
        </search>
        <option name="charting.chart">column</option>        
      </chart>
    </panel>
  </row>
</form>

skender27
Contributor

Hi,

It is exactly what i need.
The dropdown uses a token field and has some static options selections key=value and by default I need it to be appliable (YES check).
If I select the NO checkbox, the dropdown selections (so the token field) ahs no effect at all to the search string.

Should I do this by modifying the xml or by web interface?

Thanks,
Skender

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...