set
set
Synopsis
Performs set operations on subsearches.
Syntax
set (union|diff|intersect) subsearch subsearch
Required arguments
- subsearch
- Syntax: <string>
- Description: Specifies a subsearch. For more information about subsearch syntax, see "About subsearches" in the Search manual.
Description
Performs two subsearches and then executes the specified set operation on the two sets of search results:
- The result of a union operation are events that result from either subsearch.
- The result of a diff operation are the events that result from either subsearch that are not common to both.
- The result of an intersect operation are the events that are common for both subsearches.
Important: The set command works on less than 10 thousand results.
Examples
Example 1: Return values of "URL" that contain the string "404" or "303" but not both.
| set diff [search 404 | fields url] [search 303 | fields url]Example 2: Return all urls that have 404 errors and 303 errors.
| set intersect [search 404 | fields url] [search 303 | fields url]Note: When you use the fields command in your subsearches, it does not filter out internal fields by default. If you don't want the set command to compare internal fields, such as the _raw or _time fields, you need to explicitly exclude them from the subsearches:
| set intersect [search 404 | fields url | fields - _*] [search 303 | fields url | fields - _*]See also
append, appendcols, join, diff
Answers
Have questions? Visit Splunk Answers and see what questions and answers the Splunk community has using the set command.
This documentation applies to the following versions of Splunk: 5.0 , 5.0.1 , 5.0.2 , 5.0.3 View the Article History for its revisions.