14. Retrospective Query Language (RQL)¶
The Retrospective Query Language (RQL) is the language of the local filter field. It filters the entries already in the result table (see Result Visualization (Result Table)); it is never sent to a host. A query consists of one or multiple terms and groups. You combine terms and groups with Boolean operators to form a more complex query. This page describes the terms, the column operators, the wildcards, the Boolean operators, grouping and the escaping rules.
14.1. Terms¶
There are two types of terms: single terms and phrases. Phrases are surrounded by double quotation marks.
A term or phrase matches when it occurs anywhere in the raw text of a log entry, as shown in the result detail pane. A term can also match part of a word. Matching is case-insensitive unless Make local filter text case-sensitive is on. The original timestamp is not searched unless the timestamp toggle includes it; see the toggles under Local Filter Field.
14.2. Columns¶
To filter on a named column, type the column name, then an operator (=, <,
<=, >, >=), then the term you are looking for. The columns
Date/Time and Data cannot be named in a term. Column
names are case-sensitive, so type them exactly as the column header shows
them; level=ERROR reports an unknown column. Only visible columns can be
named.
The standard columns Level, Host and
Path answer both to the English name and to the name shown in
the language you are using. So Level=ERROR and Stufe=ERROR select
the same entries. A query therefore keeps working after you change the
interface language, including the queries kept in the field’s history.
Your own columns are named the way you named them, in every language.
Operator |
Description |
|---|---|
= |
The equal operator tests if the column value and the filter term are
equal. The term may contain wildcards. For a Number
column, the term may contain only digits, wildcards, a leading
minus sign and one decimal point, for example |
< |
The less than operator tests if the column value is less than the filter term. The term must not contain wildcards. |
<= |
The less than or equal operator tests if the column value is less than or equal to the filter term. The term must not contain wildcards. |
> |
The greater than operator tests if the column value is greater than the filter term. The term must not contain wildcards. |
>= |
The greater than or equal operator tests if the column value is greater than or equal to the filter term. The term must not contain wildcards. |
A term that breaks these rules makes the query invalid, and the field tooltip names the reason, for example Column <name>: bounded expression must not contain wildcards.
Note
When you use one of the bounding operators (<, <=, >, >=), the filter result may differ depending on whether the Data Type of the column is Number or Text.
For Text, Retrospective compares the column values and the filter term character by character. If the first characters match, the second ones are compared and so on. Therefore, 10 is considered less than 2, and 11 is considered greater than both 1 and 100.
For Number, Retrospective interprets the filter term as a
number, even if it is quoted (enclosed in double quotation marks). A
negative bound needs no escaping, for example Amount>-5.
Examples:
|
Filters log entries that contain “trace” in their path. |
|
Filters log entries where the column “Code” contains exactly one character. |
|
Filters log entries where the column “Name” is not empty. |
|
Filters log entries where the value of the column “ClientID” is not equal to “x”. |
|
Filters log entries where the value of the column “URL” does not start with “https”. |
|
Filters log entries where the value of the column “Amount” is less than or equal to 10. |
|
Filters log entries where the value of the column “Amount” is not greater
than 10. This is not the same as |
Note
A column name that contains one or several spaces cannot be used in an RQL term. Choose column names that do not contain spaces.
14.2.1. Log Level Column¶
When an RQL query contains a Level column term together with a
bounding operator (<, <=, >, >=), Retrospective checks the priority of
the log level of each result entry to find the matches. The priority
is also called severity. The term is compared exactly, without
wildcards, with the log level names and patterns. Entries from
Windows Event Logs compare with the Windows event level the term names, all
other entries with the configured log level it names. So Level>warning
hides the warnings of event logs, files and containers alike, also when the
term is one of the level names of your log level configuration, such as
WARN. When the term names a level of one kind only, such as debug,
every entry compares with that level. A term that matches no name or pattern
matches nothing. Entries without a log level are outside every bound;
Level=NONE selects them. Level= instead matches the log level
names, with wildcards, and only levels that occur in the result. So
Level=warning finds the Windows event level Warning but not WARN, while
Level>=warning selects both. A Windows event level also answers to its name in
the interface language, for = and for the bounds: with a German
interface, Level=Warnung and Level=Warning select the same Windows events.
Queries with the English names work in every language; a query with a name
in the interface language matches no Windows event level after you switch
to another language. The examples below assume case-insensitive
matching.
Examples:
|
Filters log entries that contain a log level with a priority that is less than or equal to the priority of the log level INFO, provided that the default log level configuration is active. In this example, “info” matches the “INFO” pattern associated with the identically named log level INFO. |
|
Filters log entries that contain a log level with a priority that is greater than or equal to the priority of the log level WARN, provided that the default log level configuration is active. In this example, “warning” matches the “WARNING” pattern associated with the log level WARN, and the Windows event level Warning, with which the entries from Windows Event Logs compare. |
You can change the priority of log levels by moving their position on the Log Level Definitions preferences page (see Log Level Definitions).
14.3. Wildcards¶
RQL supports single and multiple character wildcards within single terms and phrases. Wildcards are special characters that represent unknown characters in a text. Use them to locate sections that are similar but not identical.
Wildcard Character |
Description |
|---|---|
|
Matches a single character at a specific position. The single character wildcard search looks for terms that match with the single character replaced. For example, to search for “text” or “test”, you can use the term: te?t
|
|
Matches any number of characters. A multiple character wildcard search looks for 0 or more characters. For example, to search for “test”, “tests” or “tester”, you can use the term: test*
|
RQL interprets wildcard characters in a special manner, so escape them with a
backslash (\) to match them explicitly. To match an asterisk *, for
example, type \*.
Inside a phrase (a term surrounded by double quotation marks), you also escape a
wildcard with a single backslash. For example, "five\* solution" matches the
text “five* solution”.
14.4. Boolean Operators¶
Boolean operators combine terms through logic operators. Retrospective supports AND, OR and NOT. Boolean operators must all be uppercase to be taken into account.
Operator |
Alternatives |
Description |
|---|---|---|
OR |
|
The OR operator is the default operator. If there is no Boolean operator between two terms, Retrospective uses the OR operator. The OR operator links two terms and finds a matching log entry if it matches either of the terms. To search for log entries that contain either “out of date” or just “outdated”, use one of the following queries: "out of date" OR outdated
"out of date" || outdated
Since OR is the default operator, the same can be written as follows: "out of date" outdated
|
AND |
|
The AND operator matches log entries that contain both. To search for log entries that contain “HTTP” and “ 500 “, use one of the queries below: http AND " 500 "
http && " 500 "
http +" 500 "
|
NOT |
|
The NOT operator excludes log entries that contain the term after NOT. To search for log entries that contain “HTTP” but not “ 200 “, use one of the queries below: http NOT " 200 "
http !" 200 "
http -" 200 "
To search for log entries that contain “purchase” or do not contain “action”, use one of the following queries: purchase (NOT action)
purchase (!action)
purchase (-action)
|
14.5. Grouping¶
Use parentheses to group clauses into subqueries. Grouping lets you control the Boolean logic of a query. To exclude an entire group, place “NOT”, “!” or “-” in front of it.
Use parentheses whenever you mix operators. Without them, Retrospective
evaluates a run of terms from left to right, so a NOT or + applies to
everything left of it. For example, +a b means a OR b.
To search for log entries that contain either of the terms “out of date” or “outdated”, together with the term “message”, use the following query:
("out of date" OR outdated) AND message
You can also group clauses for columns. To search for log entries where the column “Code” contains either of the values “A”, “M” or “X”, your query could look as follows:
Code=(A OR M OR X)
or even shorter:
Code=(A M X)
14.6. Escaping Special Characters¶
Escape the special characters of the RQL syntax if you want to use them explicitly for filtering log content. RQL currently uses the following special characters:
+ - && || ! ( ) " * ? \ = < >
The characters : / { } [ ] ^ ~ @ are not special in RQL; Retrospective
escapes them automatically.
To escape a character, put the backslash \ in front of it. A search term
enclosed in double quotation marks needs no escaping. The exceptions to this
rule are the double quotation mark itself, the wildcard characters * and
? but also the backslash \. A backslash in front of any other
character is dropped, and \uXXXX stands for the Unicode character with
the hexadecimal code XXXX. A backslash at the end of a term makes the query
invalid. Write a literal backslash as \\.
To search for a phrase that contains double quotation marks, write the phrase as follows:
"Retrospective \"Release 6.0\""
To explicitly match wildcard characters enclosed in double quotation marks, escape them with a backslash
\as follows:"five\* solution" "what happened here\?"
To explicitly filter log content that contains a backslash, your search term could be written as follows:
"1\\2"
14.7. Validation¶
The field checks the query while you type. Its background is green while
the query is valid and red while it is not; the field tooltip then names
the reason. Pressing Enter applies the query. An invalid query is
never applied, neither by Enter nor by the field’s toggles or its
history, and the previous filter stays in force.
An empty phrase ("") means no filter. Filter with selection
in the result detail pane context menu refuses a selection that is not
valid RQL with Invalid RQL.