Iniciar sesión

Practice: parsing like a detection engineer

12 min · 2 ejercicio(s)

Cheat sheet

Task ES|QL
Typed capture %{INT:bytes:int}, %{NUMBER:total:double}
Custom format (?<order_id>ORD-\d{4}-\d{6})
Optional words (?:invalid user )?
One of several (?<method>password|publickey)
Fixed delimiters DISSECT message "%{a} %{b} %{c}"
Skip a part %{} (DISSECT), unnamed %{DATA} (Grok)
Parse into ECS %{IP:source.ip}, RENAME dst AS destination.ip

From exploration to pipeline

  1. Find the line types with STATS COUNT(*) BY event.dataset and a look at message.
  2. Build the pattern in ES|QL step by step, check for null rows.
  3. Name the captures after ECS fields and add types.
  4. Copy the pattern into a grok processor (escape backslashes for JSON), test with _simulate.
  5. Attach the pipeline and keep the original line in message.

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. What was stolen?

    After logging in to the admin panel, the attacker exported a table:

    … WARN  [admin] export finished table=customers rows=48213 bytes=4812330 user=admin client=203.0.113.66

    Extract table and rows. rows must be a number, the lab filters WHERE rows > 0.

  2. 2. The last quoted field

    Extract only the user agent, the last quoted field of every nginx line, into user_agent.original (without the quotes):

    203.0.113.66 - - [13/Mar/2026:21:07:00 +0000] "GET /products?id=12%27 HTTP/1.1" 500 312 "-" "sqlmap/1.8.3#stable (https://sqlmap.org)"

    Careful: "%{DATA:user_agent.original}"$ looks right but is wrong. Grok starts at the first quote of the line. Run it and look at the values.