Dashboards & Visualizations

Custom logic for dashboard - checkbox

jasontsang
New Member

I followed http://docs.splunk.com/Documentation/Splunk/6.5.0/Viz/tokens and successfully created some custom logic for a dropdown input.

Problem comes when I tried to use a checkbox instead of a dropdown.

I tried to create a custom logic on my dashboard, however, the problem is that $value$ does not return all the values that I checked.

<input type="checkbox" token="field1">
        <label>field1</label>
        <choice value="1">1</choice>
        <choice value="7">7</choice>
        <choice value="30">30</choice>
        <change>
          <condition>
            <set token="query">(days=$value$)</set>
          </condition>
        </change>
        <delimiter> ,</delimiter>
      </input>

The problem is that $value$ does not return something like "1,7,30", instead, I could only get a single value, which is not enough for my further calculation. Any ways that I can get the full list of checked options? Thanks!

0 Karma

gokadroid
Motivator

In this line <set token="query">(days=$value$)</set> try to replace $value$ with $field1$. The checkbox input token is field1 for your code as seen in this line :- <input type="checkbox" token="field1">.

Please see the code below where I was able to extract all the three values in a comma separated text and used it in the title of the panel and also in the text of the text box. Hope it helps.

<form>
  <label>answers</label>
  <fieldset submitButton="false">
    <input type="checkbox" token="field1">
      <choice value="1">aa</choice>
      <choice value="12">bb</choice>
      <choice value="13">cc</choice>
      <change>
        <condition>
          <set token="query">(days=$field1$)</set>
        </condition>
      </change>
      <delimiter>,</delimiter>
    </input>
    <input type="text" token="field2">
      <default>$field1$</default>
    </input>
  </fieldset>
  <row>
    <panel>
      <table>
        <title>Panel title =  $field1$</title>
        <search>
          <query>$field1$</query>
          <earliest>0</earliest>
        </search>
        <option name="wrap">undefined</option>
        <option name="rowNumbers">undefined</option>
        <option name="drilldown">row</option>
        <option name="dataOverlayMode">none</option>
        <option name="count">10</option>
      </table>
    </panel>
  </row>
</form>
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!

What Is Splunk? Here’s What You Can Do with Splunk

Hey Splunk Community, we know you know Splunk. You likely leverage its unparalleled ability to ingest, index, ...

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...

Manual Instrumentation with Splunk Observability Cloud: How to Instrument Frontend ...

Although it might seem daunting, as we’ve seen in this series, manual instrumentation can be straightforward ...