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

Revered Legend

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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...