Dashboards & Visualizations

How to provoke a specific code depending on value of input?

telecomdesign
New Member

Hello,
I am trying to code a dashboard on Splunk.
I have a value of an input and would like to realize a specific code if the result of my input is A and another one if the input is B.
I was looking at the if condition but I didn't find anything correct.
Could you help me?

Thanks a lot.

0 Karma

renjith_nair
Legend

@telecomdesign,

If you are looking for executing searches with minor changes with respect to field values , you can use tokens from the input panel.

Reference : https://docs.splunk.com/Documentation/Splunk/7.3.0/Viz/tokens#Define_tokens_for_form_inputs

If your searches are entirely different, then probably create two panels with respective searches and show/hide one of them based on your inputs.

Please find a run anywhere example with dropdown input. You could also use radio buttons or other inputs

Just copy & paste the xml to a dashboard and it should work

<form>
  <label>Conditional Inputs</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="inputs">
      <label>field1</label>
      <choice value="search1">Input A</choice>
      <choice value="search2">Input B</choice>
      <initialValue>search1</initialValue>
      <change>
        <condition value="search1">
          <set token="search_one"></set>
          <unset token="search_two"></unset>
        </condition>
        <condition value="search2">
          <unset token="search_one"></unset>
          <set token="search_two"></set>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel depends="$search_one$">
      <table>
        <search>
          <query>| makeresults| eval param="SEARCH1"</query>
          <earliest>-15m</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
        <panel depends="$search_two$">
      <table>
        <search>
          <query>| makeresults| eval param="SEARCH2"</query>
          <earliest>-15m</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">none</option>
      </table>
    </panel>
  </row>
</form>
---
What goes around comes around. If it helps, hit it with Karma 🙂
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!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...