Admin Manual

 


How Splunk Works

Form searches

This documentation does not apply to the most recent version of Splunk. Click here for the latest version.

Form searches

Form searches are saved searches that appear as forms when run. Save any search with parameters to be specified by the user running the search. The user fills in the parameters before running the search. You can create a sophisticated saved search and save it as a form with as many form fields as you like.


For example, you can define a search that returns all Web server errors for any username to be specified at search time:


503 OR 500 OR 404 sourcetype=access_common $user$

When run, this search appears as a form labeled user.


FormSearch-user.jpg


The search 503 OR 500 OR 404 sourcetype=access_common is still part of the search, but does not appear to the user.


Note: Form search works via text substitution, so the form fields can consist of anything, not just an indexed or an extracted field.


Create a form search

Create a form search the same way you create a saved search, with these additional steps:


For example, the search


$foo$

will appear as the following:


FormSearch-foo.jpg


Form searches with fields

Create form searches for indexed and extracted fields.


Preface your form field with the field name and surround the form field with quotes.


For example:


index=_internal AND sourcetype=splunkd

can be made into a general (form) search for any sourcetype by adding sourcetype after the indexed field name and surrounding it with dollar signs:


index=_internal AND sourcetype="$sourcetype$"

Save this search as Daily indexing volume, and a user running the search sees:


FormSearch-DailyIndexingVolume2.jpg


Form searches with predefined values

You can also specify form searches that have a list of valid values. The form generated will show a drop-down list. For example, the search


sourcetype=_trade_entry AND TradeID="$Trade ID$" AND TradeType $TradeType=Accepted,Rejected,Hold$

This search limits TradeType to three values and presents them in a drop-down:


FormSearch-SavedSearchDropList.png


Valid values can also come from an external source. For example:


$user={/static/html/imap.users}$ 

Note: The external source must be accessible as a URL from the local domain. The file should live in $SPLUNK_HOME/share/splunk/search_oxiclean/static/html, should be a plain text file and contain the values that you want to show in the drop-down list in the following format:


['value1','value2','value3','value4']


Share your form search

Once you have refined your search, you can distribute it to your users.


Save it

Permalink it

This documentation applies to the following versions of Splunk: 3.2 , 3.2.1 , 3.2.2 , 3.2.3 , 3.2.4 , 3.2.5 , 3.2.6 View the Article History for its revisions.


You must be logged into splunk.com in order to post comments. Log in now.

Was this documentation topic helpful?

If you'd like to hear back from us, please provide your email address:

We'd love to hear what you think about this topic or the documentation as a whole. Feedback you enter here will be delivered to the documentation team.

Feedback submitted, thanks!