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 allow you to create reusable searches for casual or non-technical Splunk users. Form searches are saved searches that appear as forms with parameters to be specified by the user running the search. The user doing the searching must fill in these parameters, or form fields before running the search. You can create a very complicated 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 a username that the user doing the searching specifies:


503 OR 500 OR 404 sourcetype::access_common user::$user$

This search appears as a form labeled user.


FormSearch-user.jpg


The search 503 OR 500 OR 404 sourcetype::access_common is still contained in the form search, but does not appear to the user.


Note: Form search works via text substitution so the changeable part of a search can be anything, not just a search 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

You can also create form searches for search and extracted fields.


With search fields

Preface your form field with the search field name.


The search:


index::_internal AND sourcetype::splunkd | eval "Daily indexing volume in MB" = todaysBytesIndexed/1024/1024 | timechart span=1d max("Daily indexing volume in MB")

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


index::_internal AND sourcetype::$sourcetype$ | eval "Daily indexing volume in MB" = todaysBytesIndexed/1024/1024 | timechart span=1d max("Daily indexing volume in MB")

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


FormSearch-DailyIndexingVolume2.jpg


Note that the timerange default value is the one set by the user in preferences. Time-based search modifiers cannot be used as part of a form in a form search.


With extracted fields

Note:Form searches with extracted fields require that you add the where command to your search when identifying the extracted field to be used in the form.


The search:


sourcetype=_trade_entry AND TradeID::3456

can be made into a general (form) search for any trade id by adding a where command to your search containing the TradeID after the extracted field name and surrounding it with dollar signs:


sourcetype=_trade_entry | where TradeID=$TradeID$

Save this search as trade_entry, and a user running the search sees:


FormSearch-SavedSearch.png


A user may change the TradeID to any value they want to search on.


Note that the timerange default value is the one set by the user in preferences. Time-based search modifiers cannot be used as part of a form in a form search.


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={/v3/custom/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


Share your form search

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


Save it

Permalink it

Note: Splunk doesn't Uuencode its Permalink URLs. Some browsers may experience problems resolving Permalinks if they aren't Uuencoded.

This documentation applies to the following versions of Splunk: 3.1 , 3.1.1 , 3.1.2 , 3.1.3 , 3.1.4 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!