category where condition
10 min · 2 ejercicio(s)
EQL describes events and chains of events. Every query starts with an event category, the keyword where and a condition:
process where process.name == "whoami.exe"The category is read from the field event.category (ECS). In the lab index lab-endpoint you find the categories process, network and file. The special category any matches every event:
any where host.name == "wks-fin-07"EQL requires a timestamp field (@timestamp) and returns events in chronological order. That is a big difference to KQL, where results are sorted by relevance unless you sort them yourself.
Comparison operators
| Operator | Meaning |
|---|---|
==, != |
equal, not equal (case sensitive) |
: |
equal, case insensitive, supports wildcards: process.name : "power*" |
<, <=, >, >= |
numeric and string comparison |
in, in~ |
in a list (in~ is case insensitive) |
like, like~ |
wildcard match (* and ?) |
regex, regex~ |
regular expression |
and, or, not |
boolean logic |
Strings use double quotes. Backslashes must be escaped ("C:\\Windows"), or you use raw strings with triple quotes: """C:\Windows""".
🔎 Profundiza: funciones, errores habituales y práctica
How EQL runs
EQL is executed by the _eql/search API of Elasticsearch. Required fields:
| Setting | Default | Note |
|---|---|---|
timestamp_field |
@timestamp |
must be a date |
event_category_field |
event.category |
the "process", "network" … before where |
tiebreaker_field |
none | orders events with the same timestamp, e.g. event.sequence |
size |
10 | number of events or sequences returned |
In Elastic Security you write EQL in Timeline (correlation tab) and in event correlation rules.
Event categories in ECS
authentication, configuration, database, driver, file, host, iam, intrusion_detection, malware, network, package, process, registry, session, web. Endpoint data mostly uses process, network, file and registry.
Optional fields
A field that doesn't exist in the mapping makes the query fail. Prefix it with ? to treat it as optional: process where ?process.pe.original_file_name == "rundll32.exe". Useful when one rule runs across several data sources.