Dashboards & Visualizations

Pass the label of an input to the title of a panel

Path Finder

Hi,

I have multiselect input and here's the code"

<label>Type</label>
<delimiter> </delimiter>
<choice value="*">All</choice>
<default>*</default>
<initialValue>*</initialValue>
<fieldForLabel>Ticket Type</fieldForLabel>
<fieldForValue>Ticket Type</fieldForValue>
<search base="baseSearch">
<query>| stats count by "Ticket Type"</query>
</search>

It generates to values, "Incidents" and "Service Request".
And using the token, I was able to pass the value to the title of a panel.
Now, what I'm trying to do is to pass the static label, which is the "All" to the title of the panel as well.

How will I able to do that?

Tags (3)
0 Karma
1 Solution

SplunkTrust
SplunkTrust

@jvmerilla, Dropdown input has default tokens $value$ and $label$ available within the dropdown's change event handler. You need to add the following code to pass on the dropdown label as token.

      <change>
        <set token="tokLabel">$label$</set>
      </change>

Following is a run anywhere dashboard example:

<form>
  <label>Label for Title</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="tokType" searchWhenChanged="true">
      <label>Type</label>
      <choice value="*">All</choice>
      <choice value="Incidents">Incidents</choice>
      <choice value="Service Request">Service Request</choice>
      <default>*</default>
      <change>
        <set token="tokLabel">$label$</set>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <title>Dropdown Label is $tokLabel$</title>
      <table>
        <search>
          <query>| makeresults
| eval value="Token value is: $tokType$"
| fields - _time</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="count">20</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">none</option>
        <option name="percentagesRow">false</option>
        <option name="rowNumbers">true</option>
        <option name="totalsRow">false</option>
        <option name="wrap">true</option>
      </table>
    </panel>
  </row>
</form>

PS: You should check out Splunk Dashboard Examples App for Input Multi-token Setter example.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

To store all selected labels of a multiselect input as a comma-separated list, not just the first one, you could for example use:

<change>
<set token="tokLabel" delimiter=",">$label$</set>
</change>

prefix="" and suffix="" are also valid attributes in <set>

SplunkTrust
SplunkTrust

@jvmerilla, Dropdown input has default tokens $value$ and $label$ available within the dropdown's change event handler. You need to add the following code to pass on the dropdown label as token.

      <change>
        <set token="tokLabel">$label$</set>
      </change>

Following is a run anywhere dashboard example:

<form>
  <label>Label for Title</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="tokType" searchWhenChanged="true">
      <label>Type</label>
      <choice value="*">All</choice>
      <choice value="Incidents">Incidents</choice>
      <choice value="Service Request">Service Request</choice>
      <default>*</default>
      <change>
        <set token="tokLabel">$label$</set>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <title>Dropdown Label is $tokLabel$</title>
      <table>
        <search>
          <query>| makeresults
| eval value="Token value is: $tokType$"
| fields - _time</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
          <sampleRatio>1</sampleRatio>
        </search>
        <option name="count">20</option>
        <option name="dataOverlayMode">none</option>
        <option name="drilldown">none</option>
        <option name="percentagesRow">false</option>
        <option name="rowNumbers">true</option>
        <option name="totalsRow">false</option>
        <option name="wrap">true</option>
      </table>
    </panel>
  </row>
</form>

PS: You should check out Splunk Dashboard Examples App for Input Multi-token Setter example.

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

Communicator

The only problem with using $label$ token with multi-select is that it only displays the first element, Is there a way to display all labels separated by a comma without using any javascript?

0 Karma

Path Finder

i also have the same issue, with mulitselect how to show all the fields label seelcted

0 Karma