Dashboards & Visualizations

In the dropdown Input how can I select the second Value of a list?

Path Finder

Hello there,
I need to set as a default always the second element of my list values, the value can change but I need to take always the second one.

How can I make that?
There's a way with javascript?

Thank you.


0 Karma


@marziaolla, Try the following Run anywhere dashboard example. It uses post-processing to identify the second value in the dropdown and sets the same as a token for default value.

PS: If the search for Dropdown returns only one result, the same will be set as default value. Also in case the Search does not return any results, I have used Static All option to be set as default value.

alt text

  <label>Second Value in the list</label>
 <!-- Your Search to populate the second item from the list should go here --->
  <search base="baseComponentSearch">
    <query>| head 2 | tail 1
      <!-- In case the Search does not return any results Static Option All should be selected -->
      <condition match="$job.resultCount$==0">
        <set token="tokDefaultSelectedComponent">*</set>
      <!-- Set the token using Search Event Handler's default token result.<yourFieldName> -->
      <!-- If the Search returns two or more results 2nd result will be selected -->
      <!-- If the Search returns only one result, the same will be selected -->
        <set token="tokDefaultSelectedComponent">$result.component$</set>
  <fieldset submitButton="false">
    <input type="time" token="tokTime" searchWhenChanged="true">
    <input type="dropdown" token="tokComponent" searchWhenChanged="true">
      <label>Select Component</label>
      <search id="baseComponentSearch">
        <query>index=_internal sourcetype=splunkd log_level!="INFO" earliest="$tokTime.earliest$" latest="$tokTime.latest$"
| stats count by component
| sort - count
| head 5</query>
      <choice value="*">All</choice>
          <query>index=_internal sourcetype=splunkd log_level!=INFO component="$tokComponent$"
| timechart count by component</query>
        <option name="charting.chart">line</option>
        <option name="charting.drilldown">all</option>
        <option name="refresh.display">progressbar</option>
| makeresults | eval message= "Happy Splunking!!!"
0 Karma


Any specific reason for it? Can you move the 2nd element in the first position (at populating search level) and then set the first element (which was 2nd element before) as default?

0 Karma
Get Updates on the Splunk Community!

Splunk Observability Cloud | Unified Identity - Now Available for Existing Splunk ...

Raise your hand if you’ve already forgotten your username or password when logging into an account. (We can’t ...

Index This | How many sides does a circle have?

February 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

Registration for Splunk University is Now Open!

Are you ready for an adventure in learning?   Brace yourselves because Splunk University is back, and it's ...