Dashboards & Visualizations

How to get the name of the chosen token in drop-down input ?


I am trying to get the the name of the token selected in the drop-down, and not the value.
The drop-down has a token name "dropToken" and has three choices aaa;bbb;ccc . The three choices have different values which I use in my search string. I am able to get the value of the choice by using $dropToken". Now I want to use the the token choice in the title of the panel. How can I get the token choice?

XML snippet

  <label>Choose a Consumer</label>
  <choice value="value specific to aaa">aaa/choice>
  <choice value="value specific to bbb">bbb</choice>
  <choice value="value specific to ccc">ccc</choice>

Now I want to take the value of the drop-down choice and use the same in the title of the panel, where this choice is used to derive the chart. like "chart for ccc"

Tags (3)


Before closing out your </input> area, add:

<set token="dropToken_label">$label$</set>

Then use $dropToken_label$ as your token for the label of $dropToken$

New Member

This WORKS! great

0 Karma

Splunk Employee
Splunk Employee

Frankly, I'd look here - http://docs.splunk.com/Documentation/Splunk/6.2.2/Viz/tokens#Access_labels_and_values_of_form_inputs

It shows you how to access input labels to use in titles.

Hi rajparekh08,
I understand that you want to use these values to display in the panel title. Well I can get them and display them in a table or chart, let me show it, may be someone can use it to finalise the answer.
1- after creating your dropdown with your choices (aaa=host, bbb=source,ccc=sourcetype ) and your token;
2- build your search string using eval command and if(). for example :

index=_internal |stats count|eval choice=if("$token$"="host","aaa",if("$token$"="source","bbb","ccc"))|table count choice

This display count and what we want to put in the panel title.

0 Karma


Hi rajparekh08
In your dropdown input add this


And define your panel title like this

<title> drop_Token="$drop_Token$" </title>
0 Karma

Hi rajparekh,

Try to add this code your mark < panel>


my xml code is look like this :

  <fieldset submitButton="false">
    <input type="checkbox" token="categoryId" searchWhenChanged="true">
      <label>Choose your CategoryId</label>
      <choice value="STRATEGY">aaa</choice>
      <choice value="SIMULATION">BBB</choice>
      <choice value="TEE">ccc</choice>

          <query>sourcetype="access_combined_wcookie"  action=purchase $categoryId$|stats count by categoryId</query>
        <option name="wrap">true</option>
        <option name="rowNumbers">false</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">cell</option>
        <option name="count">10</option>
0 Karma
State of Splunk Careers

Access the Splunk Careers Report to see real data that shows how Splunk mastery increases your value and job satisfaction.

Find out what your skills are worth!