Query Syntax
Here is how you search through your log events
Log event structure
In Scanner, a log event is a collection of key-value pairs called fields. In a field, the key is always a string, and the value may be either a string or a number.
For example, a log event from application logs might look like this:
And the resulting Scanner log event would look like this:
Text queries
Type in free-form text to search for hits. By default, search is case insensitive for ASCII characters, so these match the same lines.
By default, tokens are matched separately, so these match the same lines.
Bare (unquoted) strings cannot include whitespace or any of the following characters: :()"'<>=|,~{}!`
. They also can't be any reserved keywords (see Reserved Keywords).
Use single-quotes '
if you need to match any of these characters (or if you need to match a reserved keyword).
Use double-quotes "
for exact, case-sensitive matching.
Quoted strings support escape sequences. See Escape Sequences for Strings for a comprehensive list.
Use *
for wildcard searches. You can use \*
to match the actual asterisk character instead.
Column Queries
Use column: value
to search for a column
that contains value
.
Use column = value
to search for a column
that is exactly value
.
Use column: *
or column = *
if you just want to check if a column exists at all.
Like with string values, bare (unquoted) column names cannot include whitespace or any of the following characters: :()"'<>=|,~{}!`
. They also can't be any reserved keywords (see Reserved Keywords).
Use backticks ``
to denote columns that contain spaces or other disallowed characters.
Quoted column names support escape sequences. See Escape Sequences for Strings for a comprehensive list.
Use *
or **
as a wildcard in column names. *
matches any character other than .[]
; **
matches any character. You can use \*
to match the actual asterisk character instead.
Number queries
If your log events have number fields, you can look for exact matches or inequalities.
Boolean queries
Scanner supports boolean queries using and
, or
, and not
. These are case-insensitive.
You can use parentheses to specify order of operations.
If parentheses aren't used, then not
has highest precedence, then and
, then or
, so these two queries are identical.
If omitted, the default operator is and
; i.e. any two query terms without a boolean operator will be assumed to be using and
, so the following two queries are identical.
Boolean operators can be used inside of column filters for the :
and =
operators, in which case the column filter distributes. Hence, these queries are identical.
Inside of a column filter, the default operator is or
rather than and
, so the following queries are identical.
Additional Details
Token Boundaries
A query match will always start and stop on a whole token, and will never start or stop in the middle of one.
al
will match "Al Sharpton", but not "Walt Whitman", "Alan Turing", or "Hannibal Lecter".al*
will match "Al Sharpton" and "Alan Turing", but not "Walt Whitman" or "Hannibal Lecter".al*n
will match "Alan Turing" and "Albert Einstein", but not "Walt Whitman".
Escape Sequences for Strings
You can use escape sequences for certain characters. These work in all strings, including column name strings.
Escape sequence | Character |
---|---|
| double quote |
| single quote |
| backtick |
| asterisk |
| backslash |
| forward slash |
| backspace |
| form feed |
| line feed |
| carriage return |
| horizontal tab |
| unicode character |
Reserved Keywords
The following keywords are reserved in filters: and
, or
, not
. Use quotes if you need to search for them as strings.
Last updated