where

Description

The where command uses eval-expressions to filter search results. These eval-expressions must be Boolean expressions, where the expression returns either true or false. The where command returns only the results for which the eval expression returns true.

Required arguments

Description: A combination of values, variables, operators, and functions that represent the value of your destination field. See Usage.

The syntax of the eval expression is checked before running the search, and an exception is thrown for an invalid expression.

The following table describes characteristics of eval expressions that require special handling.

Expression characteristics

Description

Example

Field names starting with numeric characters

If the expression references a field name that starts with a numeric character, the field name must be surrounded by single quotation marks.

'5minutes'="late"

This expression is a field name equal to a string value. Because the field starts with a numeric it must be enclosed in single quotations. Because the value is a string, it must be enclosed in double quotations.

Field names with non-alphanumeric characters

If the expression references a field name that contains non-alphanumeric characters, the field name must be surrounded by single quotation marks.

new=count+'server-1'

This expression could be interpreted as a mathematical equation, where the dash is interpreted as a minus sign. To avoid this, you must enclose the field name server-1 in single quotation marks.

Literal strings

If the expression references a literal string, the literal string must be surrounded by double quotation marks.

new="server-"+count

There are two issues with this example. First, server- could be interpreted as a field name or as part of a mathematical equation, that uses a minus sign and a plus sign. To ensure that server- is interpreted as a literal string, enclose the string in double quotation marks.

Usage

The where command is a distributable streaming command. See Command types.

The where command uses the same expression syntax as the eval command. Also, both commands interpret quoted strings as literals. If the string is not quoted, it is treated as a field name. Because of this, you can use the where command to compare two different fields, which you cannot use the search command to do.

Command

Example

Description

Where

... | where foo=bar

This search looks for events where the field foo is equal to the field bar.

Search

| search foo=bar

This search looks for events where the field foo contains the string value bar.

Where

... | where foo="bar"

This search looks for events where the field foo contains the string value bar.

Boolean expressions

The order in which Boolean expressions are evaluated with the where command is:

Expressions within parentheses

NOT clauses

AND clauses

OR clauses

This evaluation order is different than the order used with the search command. The search command evaluates OR clauses before AND clauses.

Functions

You can use a wide range of functions with the where command. For general information about using functions, see Evaluation functions.

The following table lists the supported functions by type of function. Use the links in the table to learn more about each function, and to see examples.

Comments

DUThibault
Thank you so much for pointing this out! Indeed the eval-expression must be Boolean. I have updated the description and removed the section in the table that was incorrect.

Lstewart splunk, Splunker

March 30, 2018

"The result of the eval expression cannot be boolean" but both examples have where-arguments that are Boolean! (example 2 is "sourcetype=physicsjobs | where distance/time > 100") "distance/time > 100" is clearly Boolean. Something is seriously wrong (or confusing) about that expression characteristics statement.

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

Send me a copy of this feedback

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

Feedback submitted, thanks!

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

Your Comment Has Been Posted Above

We use our own and third-party cookies to provide you with a great online experience. We also use these cookies to improve our products and services, support our marketing campaigns, and advertise to you on our website and other websites. Some cookies may continue to collect information after you have left our website.
Learn more (including how to update your settings) here »