Dashboards & Visualizations

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

jvmerilla
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?

Labels (1)
Tags (3)
0 Karma
1 Solution

niketn
Legend

@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

BorisGrochalski
Explorer

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>

niketn
Legend

@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!!!"

sugreev916
New Member

Thank you so much

0 Karma

ss026381
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

vikashperiwal
Path Finder

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

0 Karma
Get Updates on the Splunk Community!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...