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

Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...