Dashboards & Visualizations

How to use tokens in dashboard panel labels with checkboxes?

aferone
Builder

I understand that there is a bug in using some tokens with checkboxes and the condition tags.

I want to use the value of a token that I am using for a dashboard panel label. Here is the code for the checkbox selection:

<input type="checkbox" token="YearsAx" searchWhenChanged="true">
  <label>Select Years</label>
  <choice value="2017">2017</choice>
  <choice value="2018">2018</choice>
  <delimiter> OR </delimiter>
  <prefix>(</prefix>
  <suffix>)</suffix>
  <valuePrefix>Year="</valuePrefix>
  <valueSuffix>"</valueSuffix>
  <change>
    <condition value="2017">
      <set token="date_label">2017</set>
    </condition>
    <condition value="2018">
      <set token="date_label">2018</set>
    </condition>
  </change>
</input>

However, when I use $YearsAx$ for the dashboard panel label, I get this (a few examples):

Summary By Program (In Plan) (Year="2018" OR Year="2017")
Summary By Program (In Plan) (Year="2017")
Summary By Program (In Plan) (Year="2018")

The condition tags would normally be used to set a different token, but they don't seem to work with checkboxes.

How can I work around it so that I can show a proper dashboard label? Something like this:

 Summary By Program (In Plan) 2017 and 2018
 Summary By Program (In Plan) 2017
 Summary By Program (In Plan) 2018

Thank you!

0 Karma

sbbadri
Motivator

@aferone

Please try this

<form>
  <label>testCheckbox</label>
  <fieldset submitButton="false" autoRun="true">
    <input type="checkbox" token="YearsAx" searchWhenChanged="true">
      <label>Select Years</label>
      <choice value="2017">2017</choice>
      <choice value="2018">2018</choice>
      <delimiter> and </delimiter>
    </input>
  </fieldset>
  <row>
    <panel>
      <title>Summary By Program (In Plan) $YearsAx$</title>
      <event>
        <search>
          <query>index=_internal sourcetype=splunkd | head 1</query>
          <earliest>-15m</earliest>
          <latest>now</latest>
        </search>
      </event>
    </panel>
  </row>
</form>
0 Karma

aferone
Builder

This is what I am using now, however by using $YearsAx$, my label literally says "Years = 2017". Then if both 2017 and 2018 are selected, I get "Years = 2017 OR Years = 2018". Not ideal.

0 Karma

cmerriman
Super Champion

your using the $YearAx$ token in the label, which has (Year="2017......) defined.

try something like this:

...
<change>
     <condition>
       <set token="date_label">$value$</set>
     </condition>
   </change>
...

and use $date_label$ in the panel.

0 Karma

aferone
Builder

Right. In my example above, I am using the condition tags. I forgot to mention that I first used the $date_label$ token, but it doesn't work. I believe that is where the bug is with using checkboxes. Radio buttons do work, however.

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...