Iniciar sesión

What is EQL?

10 min · 2 ejercicio(s)

EQL (Event Query Language) is a query language built for security analytics. It was created at Endgame to describe attacker behaviour, and has been part of Elasticsearch since Elastic acquired Endgame in 2019. Where KQL asks "which documents match?", EQL asks "which events, and which chains of events, match?"

process where process.name == "whoami.exe"

That's a complete EQL query: an event category (process), the keyword where and a condition.

What makes EQL special

  • Events, not documents. Every query names the kind of event it wants: process, network, file, authentication, … EQL reads it from the ECS field event.category.
  • Time order. Results are always sorted by @timestamp. EQL thinks in timelines.
  • Sequences. The killer feature: describe several steps that must happen in this order, optionally on the same host or user and within a time window:
sequence by host.name with maxspan=5m
  [process where process.name == "WINWORD.EXE"]
  [process where process.parent.name == "WINWORD.EXE" and process.name == "powershell.exe"]

"Word starts, and within five minutes on the same host Word starts PowerShell." That's a phishing macro. KQL and ES|QL can't express this in one query.

  • Process lineage. With process.parent.* and process.entity_id you follow process trees.

Where you use EQL

Place What you do there
Elastic Security, EQL rules Detection rules for multi-step attacks. Many prebuilt rules are EQL
Timeline → Correlation tab Hunt for sequences interactively
GET index/_eql/search API Run EQL from scripts

EQL compared

KQL ES|QL EQL
Filter events ✔ ✔ ✔
Count, group, calculate ✔ (only simple pipes)
Chronological order by default ✔
Sequences of events ✔
Typical user Every Kibana user Analysts, hunters Detection engineers

Requirements

EQL needs a timestamp field (@timestamp) and an event category field (event.category). Data that follows ECS has both. All lab indices do, so in this track you mostly query lab-endpoint with its process, network and file events.

🔎 Profundiza: funciones, errores habituales y práctica

Three kinds of EQL queries

Query Returns Example
Event query Single events process where process.name == "whoami.exe"
Sequence Ordered chains of events sequence by host.name [file where …] [process where …]
Sample Groups of events that share values, in any order sample by host.name [process where …] [network where …]

Pipes such as | head 10 and | tail 5 limit the result. EQL is deliberately small: no aggregations, no joins across indices. For counting and statistics you switch to ES|QL.

Case sensitivity

== compares exactly (case sensitive), : compares case insensitively and supports wildcards. Detection rules usually use : for process names, because Windows file names are case insensitive (PowerShell.exe and powershell.exe are the same program).

Why sequences matter for detection

A single event is rarely proof of an attack: powershell.exe runs on every IT workstation. The combination with context makes it suspicious: PowerShell started by Word, followed by a network connection to a rare IP. EQL sequences let a rule express exactly that, which cuts false positives dramatically.

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. Your first event query

    Attackers often run whoami.exe right after they gain access. On which host was whoami.exe started?

  2. 2. From KQL to EQL

    In KQL you would write process.name: rclone.exe. Write the same in EQL: return every process event of rclone.exe. Your query is graded by its result.