Dashboards & Visualizations

Why is the dashboard dropdown only showing 5 values from dynamic query?

dyapasrikanth
Path Finder

The below input field only showing 5 values in dropdown and no auto complete box. I can see it try to show all fields initially and at the end of the search it just showing 5 values + default value and this is not the case all the time. Some times it is not showing anything other than default value.

<input type="dropdown" token="env">
      <label>Environment</label>
      <default>prod</default>
      <initialValue>prod</initialValue>
      <fieldForLabel>Environment</fieldForLabel>
      <fieldForValue>env_name</fieldForValue>
      <search>
        <query>index=test_*  appname=* | rename kubernetes.namespace_name as env_name | rex field=host "ab_bc-[^-]*-(?P<env_name>[^-]*)-" | sort env_name | dedup env_name | stats count by env_name</query>
        <earliest>-24h@h</earliest>
        <latest>now</latest>
      </search>
    </input>

There are 25 events from the above query and they are like this

env_name    count
mlcd1   1
mlcd2   1
mlct1   1
mlct2   1
np1 1
np10    1
np11    1
np12    1
np13    1
np14    1
np15    1
np16    1
np17    1
np18    1
np19    1
np2 1
np20    1
np3 1
np4 1
np5 1
np6 1
np7 1
np8 1
np9 1
prod    1

I am only seeing top 5 values + prod in dropdown. What's wrong with this?

0 Karma

somesoni2
Revered Legend

Your dropdown code seems incorrect per your query. For displaying data to dropdown, you've configured following:-

   <fieldForLabel>Environment</fieldForLabel>
   <fieldForValue>env_name</fieldForValue>

Values of both attribute points to a field in the search result (search result field specified in fieldForLabel will be shown as labels in dropdown and field specified in fieldForValue will be used as value for corresponding label). You search query has just env_name and count as field, so fieldForLabel is wrong here. Try this

   <fieldForLabel>env_name</fieldForLabel>
   <fieldForValue>env_name</fieldForValue>

gcusello
SplunkTrust
SplunkTrust

Hi dyapasrikanth,
I'm not sure to understand your need: your search has al the results you listed, but in th dropdown it displays only five values?

Anyway, at first in a dropdown list you can diplay only one field, so in your case your search should be:

index=test_*  appname=* 
| rename kubernetes.namespace_name as env_name 
| rex field=host "ab_bc-[^-]*-(?P<env_name>[^-]*)-" 
| stats count by env_name
| sort env_name 
| table env_name

If you want also the value of count, you have to modify your search in this way

index=test_*  appname=* 
| rename kubernetes.namespace_name as env_name 
| rex field=host "ab_bc-[^-]*-(?P<env_name>[^-]*)-" 
| stats count by env_name
| sort env_name 
| eval env_name=env_name." ".count
| table env_name

Ciao.
Giuseppe

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!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...