ThreatVIS PPL quick reference
A one-page list of the ThreatVIS PPL constructs that the console supports. For how a query is built, see ThreatVIS PPL basics. For queries to copy, see ThreatVIS PPL examples.
Shape of a query
source=log_* | where event.outcome = 'failure' | stats count() as failures by user.name | sort - failures | head 10
A query starts with a source, then stages separated by |. The time range picker adds the time condition for
you, so you never write it.
Sources
| Source | Rows |
|---|---|
source=log_* | Events from your data sources. |
source=alerts | Alerts raised by Detection Rules. |
source=cases | Cases. |
source=lookup_<name> | The rows of a lookup file. |
source=log_*,alerts | More than one source, separated by commas. |
In Search, a query that names no source runs over log_*,alerts.
Conditions in where
| Need | Write |
|---|---|
| Equals, not equals | field = 'value', field != 'value' |
| Greater, less | destination.port > 1023 |
| Text contains | like(message, '%password%') |
| Field has a value | isnotnull(user.name) |
| Field has no value | isnull(user.name) |
| Match a phrase in a field | match_phrase(message, 'failed logon') |
| Search every field | query_string(["*"], 'password') |
| Combine | and, or, not, with brackets |
Write text values in single quotes. Write a single quote inside a value twice: 'O''Brien'. Put field names
with characters other than letters, digits, underscore and dot in backticks, for example `@timestamp`.
Commands
| Command | What it does | Example |
|---|---|---|
where | Keeps rows that match a condition. | where user.name = 'jdoe' |
fields | Keeps only the named fields. | fields host.hostname, user.name |
rename | Gives a field another name. | rename user.name as account |
eval | Adds a field computed from others. | eval user_lower = lower(user.name) |
dedup | Keeps one row for each value of a field. | dedup host.hostname |
sort | Orders rows. A - before the field means descending. | sort - failures |
head | Keeps the first rows. from skips rows. | head 50, head 50 from 100 |
stats | Computes values, optionally for each group. | stats count() as events by host.hostname |
top | The most common values of a field. | top 10 source.ip |
timechart | Values over time, in buckets of a span. | timechart span=1h count() |
lookup | Adds columns from a lookup file. | lookup lookup_critical_systems hostname as host.hostname output owner |
A fields stage removes every field you do not name, including the time column.
Functions in stats
count(), sum(field), avg(field), min(field), max(field) and dc(field), the count of distinct values.
Name a result with as: stats count() as events by host.hostname. Spans for timechart are a number and a
unit, such as 5m, 1h or 1d.
lookup
lookup <file> <column> as <event field> output <columns> adds the columns to each event. They replace a field
of the same name. Use append in place of output to fill a field only when the event has no value for it.
Events that match nothing are kept, with empty added columns. To keep only the matches, add
| where isnotnull(<column>). See Use lookups in a search.
Variables and saved queries
| Write | Meaning |
|---|---|
$currentUser() | Your own user. ThreatVIS Unified Security Operations Platform replaces it each time the query runs. |
$filter(Name) or $filter("Name with spaces") | A saved Filter Query. It must be the first stage. |