Skip to main content

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​

SourceRows
source=log_*Events from your data sources.
source=alertsAlerts raised by Detection Rules.
source=casesCases.
source=lookup_<name>The rows of a lookup file.
source=log_*,alertsMore than one source, separated by commas.

In Search, a query that names no source runs over log_*,alerts.

Conditions in where​

NeedWrite
Equals, not equalsfield = 'value', field != 'value'
Greater, lessdestination.port > 1023
Text containslike(message, '%password%')
Field has a valueisnotnull(user.name)
Field has no valueisnull(user.name)
Match a phrase in a fieldmatch_phrase(message, 'failed logon')
Search every fieldquery_string(["*"], 'password')
Combineand, 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​

CommandWhat it doesExample
whereKeeps rows that match a condition.where user.name = 'jdoe'
fieldsKeeps only the named fields.fields host.hostname, user.name
renameGives a field another name.rename user.name as account
evalAdds a field computed from others.eval user_lower = lower(user.name)
dedupKeeps one row for each value of a field.dedup host.hostname
sortOrders rows. A - before the field means descending.sort - failures
headKeeps the first rows. from skips rows.head 50, head 50 from 100
statsComputes values, optionally for each group.stats count() as events by host.hostname
topThe most common values of a field.top 10 source.ip
timechartValues over time, in buckets of a span.timechart span=1h count()
lookupAdds 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​

WriteMeaning
$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.

Next steps​