Dashboards & Visualizations

How do I get each unique value for a field to appear in a drop-down list?

brutecat
Path Finder

As much as I have tried every variant in the potential answers, I can't make this work. I have the following code:

    <input type="dropdown" token="machine_tok" searchWhenChanged="true">
  <label>Select a machine</label>
        <prefix>Machine_Name="</prefix>
  <suffix>"</suffix>

  <choice value="*">ND001913</choice>
   <default>ND001913</default>

     <search>
     <query>index=nextgen_machine | stats values(Machine_Name) as machines</query>


     </search>
     <fieldForLabel>machine</fieldForLabel>
    <fieldForValue>machine</fieldForValue>

    </input>

Which displays the default value of ND001913. The other values are found, but presented as a comma delimited list as only one single other value. How to I get this to return one item in the drop-down for one unique value?

Tags (2)
0 Karma
1 Solution

gyslainlatsa
Motivator

hi,
Do not use values()

try like this

 <input type="dropdown" token="machine_tok" searchWhenChanged="true">
   <label>Select a machine</label>
         <prefix>Machine_Name="</prefix>
         <suffix>"</suffix>

    <choice value="*">ND001913</choice>
    <default>ND001913</default>

      <search>
      <query>index=nextgen_machine | stats count by Machine_Name </query>

      </search>
      <fieldForLabel>Machine_Name</fieldForLabel>
     <fieldForValue>Machine_Name</fieldForValue>
     </input>

if the field name in your events is rather machine instead of Machine_Name, must be replaced Machine_Name by machine

View solution in original post

0 Karma

gyslainlatsa
Motivator

hi,
Do not use values()

try like this

 <input type="dropdown" token="machine_tok" searchWhenChanged="true">
   <label>Select a machine</label>
         <prefix>Machine_Name="</prefix>
         <suffix>"</suffix>

    <choice value="*">ND001913</choice>
    <default>ND001913</default>

      <search>
      <query>index=nextgen_machine | stats count by Machine_Name </query>

      </search>
      <fieldForLabel>Machine_Name</fieldForLabel>
     <fieldForValue>Machine_Name</fieldForValue>
     </input>

if the field name in your events is rather machine instead of Machine_Name, must be replaced Machine_Name by machine

0 Karma

brutecat
Path Finder

gyslainlatsa,

Thanks so much. I thought I had tried this. The behaviour of 'values' does not seem consistent here.

Anyway, thanks again,

Stan

0 Karma

gyslainlatsa
Motivator

Your are welcome, don't forget to vote my answers

Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...