How to add drop-downs
This documentation does not apply to the most recent version of Splunk. Click here for the latest version.
How to add drop-downs
Create a form search with dynamic drop-downs. This means you can specify a search to autopopulate drop-down choices. Anyone who uses your form can pick between the radio buttons to populate the final search.
Start your drop-down form
Take the form search from step 1:
<form>
<label>Username</label>
<searchTemplate>sourcetype=logins $username$</searchTemplate>
<fieldset>
<input type="text" token="username" />
</fieldset>
<row>
<event>
<option name="count">100</option>
</event>
</row>
</form>
Now, change the <input type="text"> tag to dropdown and add a populatingSearch to generate the options for the drop-down:
<input type="dropdown" token="username">
<label>Select Name</label>
<populatingSearch fieldForValue="suser" fieldForLabel="suser"><![CDATA[sourcetype=p4change | rex "user=(?<suser>\w+)@"
| stats count by suser]]></populatingSearch>
</input>
Here's what the final product looks like:
<input type="dropdown" token="username">
<label>Select Name</label>
<populatingSearch fieldForValue="suser" fieldForLabel="suser"><![CDATA[sourcetype=p4change | rex "user=(?<suser>\w+)@"
| stats count by suser]]></populatingSearch>
<default>nagrin</default>
<choice value="*">Any</choice>
</input>
<row>
<table>
<title>Users</title>
<option name="showPager">true</option>
</table>
</row>
Configuration options
There are more configuration options you can set on <input type=dropdown>. For example, you can add a label to appear next to the drop-down, or specify a search to populate the drop-down, etc. None of these options are required, but they do make the drop-down more useful.
Here are all your options for configuration:
- label = label
- A label to place next to the generated drop-down.
- default = option
- The default option to select. If the default option cannot be found, the first option is selected.
- prefix
- See description for input type="text".
- suffix
- See description for input type="text".
- choice
- Requires a value attribute. eg "bar". A drop-down option declared by the user. These appear in the order they are defined and before any options generated by an underlying search.
- populatingSearch
- A search used to generate fields for the drop-down.
- Attributes :
- "fieldForValue" : Required. This is the field extracted from the populatingSearch and placed in the value of the generated drop-down option.
- "fieldForLabel" : Required. This is the field extracted from the populatingSearch and placed in the label of the generated drop-down.
- "earliest" : Optional. Earliest time set in Splunk time format.
- "latest" : Optional. Latest time set in Splunk time format.
- populatingSavedSearch
- Takes the same required attributes as populatingSearch, except instead of defining a search string, a saved search name is required. This saved search is used to populate the radio elements.
- Attributes :
- "fieldForValue" : Required. This is the field extracted from the populatingSavedSearch and placed in the value of the generated drop-down option.
- "fieldForLabel" : Required. This is the field extracted from the populatingSavedSearch and placed in the label of the generated drop-down.
This documentation applies to the following versions of Splunk: 4.1 , 4.1.1 , 4.1.2 , 4.1.3 , 4.1.4 , 4.1.5 , 4.1.6 , 4.1.7 , 4.1.8 View the Article History for its revisions.