ThreatVIS PPL examples
In this tutorial you investigate a burst of failed sign-ins. You start with a plain list of events, narrow it, count it, group it, and finish with a chart and a lookup. Each step builds on the one before, and each ends with a checkpoint that says what you should see.
Role needed: Search: Read.
Before you start
- Your appliance must receive authentication events from at least one data source. The queries use the field names that ThreatVIS Unified Security Operations Platform gives events:
event.category,event.outcome,event.code,user.name,host.hostnameandsource.ip. Which of these a source fills depends on the source, so use the Filters panel to see the fields your events have. - The host names, user names and addresses below are made up. The addresses are from ranges reserved for documentation (
192.0.2.0/24,198.51.100.0/24,203.0.113.0/24). Replace them with values from your own events. - Read ThreatVIS PPL basics first if you have not written a query before.
- Set the time range to Last 24 Hours in the time range picker. See Choose a time range and time zone.
Step 1: list the failed sign-ins
Select Search, type the query, and select Run.
source=log_* | where event.category = 'authentication' and event.outcome = 'failure'
The where stage keeps authentication events that failed.
Checkpoint. The event list shows only failed authentication events, and the footer shows the number matched. The histogram above the list shows when they happened. If nothing matches, check the time range and the fields in the Filters panel; your sources may name the outcome differently. See Search returns no results.
Step 2: look for one account
Add a condition for a user. Either type it, or open user.name in the Filters panel and select the plus button beside a value, which adds the condition for you.
source=log_* | where event.category = 'authentication' and event.outcome = 'failure' and user.name = 'jdoe'
Checkpoint. Only events for jdoe remain. Open one with its chevron to read every field, including the host and the source address.
Step 3: count by account
Replace the query with an aggregation. count() counts the events in each group, and sort - failures puts the largest first.
source=log_* | where event.category = 'authentication' and event.outcome = 'failure' | stats count() as failures by user.name | sort - failures | head 10
Checkpoint. The view switches to Table, with a user.name column and a failures column of at most ten rows. The accounts with the most failures are at the top.
Step 4: see how many places each account failed from
An account that fails from many hosts or addresses is more worrying than one that fails often from one.
source=log_* | where event.category = 'authentication' and event.outcome = 'failure' | stats count() as failures, dc(source.ip) as addresses, dc(host.hostname) as hosts by user.name | sort - addresses | head 10
dc() counts distinct values.
Checkpoint. The table now has failures, addresses and hosts columns, and the accounts are ordered by the number of addresses.
Step 5: find the busiest hours
Count failures over time to see when the burst began.
source=log_* | where event.category = 'authentication' and event.outcome = 'failure' | timechart span=1h count()
Checkpoint. The table lists the failures counted for each hour. Open the view menu and select Time Chart to draw it. See Visualise results.
Step 6: chart the top sources
Count failures by source address, keep the top five, and draw them.
source=log_* | where event.category = 'authentication' and event.outcome = 'failure' | stats count() as failures by source.ip | sort - failures | head 5
Open the view menu above the results and select Bar Chart or Pie Chart.
Checkpoint. The chart shows five bars or slices, one per address.
Step 7: keep the events and choose your own order
To list events rather than counts, and order them yourself, end the query with head. A query that ends with head is run exactly as written and returns at most that many rows. This lists up to 20 failed attempts by one account, oldest first.
source=log_* | where event.category = 'authentication' and event.outcome = 'failure' and user.name = 'jdoe' | sort `@timestamp` | head 20
Checkpoint. The event list shows up to 20 events in time order, oldest first.
Step 8: search for a word
You do not have to know the field. A plain word searches every field.
password
Search runs it as a search over events and alerts for that text. Combine it with a condition by writing the full query:
source=log_* | where query_string(["*"], 'lockout') and host.hostname = 'dc-01'
Checkpoint. Events containing the text show, with the matched host only in the second query.
Step 9: add context from a lookup file
If your administrators keep a lookup file of critical hosts, you can mark the events that touch them. The file here is called critical_systems and has the columns hostname and owner. Its query name is lookup_critical_systems.
source=log_* | where event.outcome = 'failure' | lookup lookup_critical_systems hostname as host.hostname output owner | where isnotnull(owner)
Checkpoint. Every event shows an owner field, and only events on listed hosts remain. See Use lookups in a search.
What you learned
- A query is a source followed by stages;
wherefilters,statsandtimechartsummarise,sortandheadorder and limit. - A plain word or a stage without a source is completed for you.
- The view changes to a table when the query summarises, and a chart is one selection away.
- A query that ends with
headis run exactly as written.
Next steps
- Act on a field value: build these filters by selecting values instead of typing.
- Save, share and export a search: keep a query you will use again.