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!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

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