Iniciar sesión

Practice: shaping results

12 min · 2 ejercicio(s)

Cheat sheet

FROM lab-auth                          // source
| WHERE service.name == "rdp"          // filter rows
| SORT @timestamp DESC                 // order
| KEEP @timestamp, user.name, host.name // choose columns
| LIMIT 20                             // cap the result
Command Purpose Watch out
FROM Index or pattern, e.g. lab-* Wildcards combine indices with different fields
WHERE Filter with ==, !=, <, AND, OR, NOT Strings use double quotes
SORT Order, ASC/DESC, NULLS LAST Sort before LIMIT
KEEP / DROP Choose or remove columns Wildcards work: KEEP host.*
RENAME RENAME source.ip AS ip
LIMIT Max rows Default limit is 1000 rows

Order matters

Each command works on the output of the previous one. LIMIT 1 | SORT bytes DESC takes any row and then sorts one row. SORT bytes DESC | LIMIT 1 returns the largest. Read your query top-down and ask "what does the table look like now?".

NULL values

Rows without a field have null there. WHERE source.bytes IS NOT NULL removes them before sorting, otherwise they may appear first or last depending on NULLS FIRST/LAST.

Ejercicios prácticos de esta lección

Resuelve estos ejercicios con una consulta en el laboratorio Elasticsearch real. Inicia sesión gratis para acceder al laboratorio, las pistas y la corrección automática.

  1. 1. How many connections?

    How many network events (event.category == "network") are in lab-endpoint? Return the number in a column called connections.

  2. 2. RDP sessions

    List all rdp logons in lab-auth with only the columns @timestamp, user.name and host.name, oldest first. Graded on the user.name column.