Splunk Cloud

Search Reference

Download manual as PDF

Download topic as PDF



Retrieves event metadata from indexes based on terms in the <logical-expression>. Metadata fields include source, sourcetype, host, _time, index, and splunk_server.


metasearch [<logical-expression>]

Optional arguments

Syntax: <time-opts>|<search-modifier>|((NOT)? <logical-expression>)|<index-expression>|<comparison-expression>|(<logical-expression> (OR)? <logical-expression>)
Description: Includes time and search modifiers, comparison and index expressions.

Logical expression

Syntax: <field><cmp><value>
Description: Compare a field to a literal value or values of another field.
Syntax: "<string>"|<term>|<search-modifier>
Syntax: (<timeformat>)? (<time-modifier>)*

Comparison expression

Syntax: = | != | < | <= | > | >=
Description: Comparison operators.
Syntax: <string>
Description: The name of a field. In metasearch, only the fields source, sourcetype, host, _time, index, and splunk_server can be used.
Syntax: <string> | <num>
Description: An exact, or literal, value of a field that is used in a comparison expression.
Syntax: <lit-value> | <field>
Description: In comparison-expressions, the literal value of a field or another field name where "literal" means number or string.

Index expression

Syntax: <field-specifier>|<savedsplunk-specifier>|<tag-specifier>

Time options

The search allows many flexible options for searching based on time. For a list of time modifiers, see the topic "Time modifiers for search" in the Search Manual.

Syntax: timeformat=<string>
Description: Set the time format for starttime and endtime terms. By default, timestamp is formatted: timeformat=%m/%d/%Y:%H:%M:%S .
Syntax: earliest=<time_modifier> | latest=<time_modifier>
Description: Specify start and end times using relative or absolute time. For more about the time modifier index, see "Specify time modifiers in your search" in the Search Manual.


Example 1:

Return metadata for events with "404" and from host "webserver1".

... | metasearch 404 host="webserver1"

See also

metadata, search


Have questions? Visit Splunk Answers and see what questions and answers the Splunk community has using the metasearch command.


This documentation applies to the following versions of Splunk Cloud: 7.0.0, 6.5.1, 6.5.1612, 6.6.0, 6.6.1, 6.6.3, 6.5.0

Was this documentation topic helpful?

Enter your email address, and someone from the documentation team will respond to you:

Please provide your comments here. Ask a question or make a suggestion.

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

Please try to keep this discussion focused on the content covered in this documentation topic. If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk, consider posting a question to Splunkbase Answers.

0 out of 1000 Characters