search command: Examples

The following are examples for using the SPL2 search command. To learn more about the search command, see How the SPL2 search command works.

1. Field-value pair matching

This example shows field-value pair matching for specific values of source IP (src) and destination IP (dst).

2. Using boolean and comparison operators

This example shows field-value pair matching with boolean and comparison operators. This example searches for events with code values of either 10, 29, or 43 and any host that is not "localhost", and an xqp value that is greater than 5.

An alternative is to use the IN operator, because you are specifying multiple field-value pairs on the same field. The revised search is:

3. Using wildcards

This example shows field-value pair matching with wildcards. This example searches for events from all of the web servers that have an HTTP client and server error status.

An alternative is to use the IN operator, because you are specifying two field-value pairs on the same field. The revised search is:

4. Using the IN operator

This example shows how to use the IN operator to specify a list of field-value pair matchings. In the events from an access.log file, search the action field for the values addtocart or purchase.

5. Using the NOT or != comparisons

Searching with the boolean "NOT" comparison operator is not the same as using the "!=" comparison.

The following search returns everything except fieldA="value2", including all other fields.

The following search returns events where fieldA exists and does not have the value "value2".

If you use a wildcard for the value, NOT fieldA=* returns events where fieldA is null or undefined, and fieldA!=* never returns any events.