- Elasticsearch Guide: other versions:
- What is Elasticsearch?
- What’s new in 7.10
- Getting started with Elasticsearch
- Set up Elasticsearch
- Installing Elasticsearch
- Configuring Elasticsearch
- Setting JVM options
- Secure settings
- Auditing settings
- Circuit breaker settings
- Cluster-level shard allocation and routing settings
- Cross-cluster replication settings
- Discovery and cluster formation settings
- Field data cache settings
- HTTP
- Index lifecycle management settings
- Index management settings
- Index recovery settings
- Indexing buffer settings
- License settings
- Local gateway settings
- Logging
- Machine learning settings
- Monitoring settings
- Node
- Network settings
- Node query cache settings
- Search settings
- Security settings
- Shard request cache settings
- Snapshot lifecycle management settings
- Transforms settings
- Transport
- Thread pools
- Watcher settings
- Important Elasticsearch configuration
- Important System Configuration
- Bootstrap Checks
- Heap size check
- File descriptor check
- Memory lock check
- Maximum number of threads check
- Max file size check
- Maximum size virtual memory check
- Maximum map count check
- Client JVM check
- Use serial collector check
- System call filter check
- OnError and OnOutOfMemoryError checks
- Early-access check
- G1GC check
- All permission check
- Discovery configuration check
- Bootstrap Checks for X-Pack
- Starting Elasticsearch
- Stopping Elasticsearch
- Discovery and cluster formation
- Add and remove nodes in your cluster
- Full-cluster restart and rolling restart
- Remote clusters
- Set up X-Pack
- Configuring X-Pack Java Clients
- Plugins
- Upgrade Elasticsearch
- Index modules
- Mapping
- Text analysis
- Overview
- Concepts
- Configure text analysis
- Built-in analyzer reference
- Tokenizer reference
- Token filter reference
- Apostrophe
- ASCII folding
- CJK bigram
- CJK width
- Classic
- Common grams
- Conditional
- Decimal digit
- Delimited payload
- Dictionary decompounder
- Edge n-gram
- Elision
- Fingerprint
- Flatten graph
- Hunspell
- Hyphenation decompounder
- Keep types
- Keep words
- Keyword marker
- Keyword repeat
- KStem
- Length
- Limit token count
- Lowercase
- MinHash
- Multiplexer
- N-gram
- Normalization
- Pattern capture
- Pattern replace
- Phonetic
- Porter stem
- Predicate script
- Remove duplicates
- Reverse
- Shingle
- Snowball
- Stemmer
- Stemmer override
- Stop
- Synonym
- Synonym graph
- Trim
- Truncate
- Unique
- Uppercase
- Word delimiter
- Word delimiter graph
- Character filters reference
- Normalizers
- Index templates
- Data streams
- Ingest node
- Search your data
- Query DSL
- Aggregations
- Bucket aggregations
- Adjacency matrix
- Auto-interval date histogram
- Children
- Composite
- Date histogram
- Date range
- Diversified sampler
- Filter
- Filters
- Geo-distance
- Geohash grid
- Geotile grid
- Global
- Histogram
- IP range
- Missing
- Nested
- Parent
- Range
- Rare terms
- Reverse nested
- Sampler
- Significant terms
- Significant text
- Terms
- Variable width histogram
- Subtleties of bucketing range fields
- Metrics aggregations
- Pipeline aggregations
- Bucket aggregations
- EQL
- SQL access
- Overview
- Getting Started with SQL
- Conventions and Terminology
- Security
- SQL REST API
- SQL Translate API
- SQL CLI
- SQL JDBC
- SQL ODBC
- SQL Client Applications
- SQL Language
- Functions and Operators
- Comparison Operators
- Logical Operators
- Math Operators
- Cast Operators
- LIKE and RLIKE Operators
- Aggregate Functions
- Grouping Functions
- Date/Time and Interval Functions and Operators
- Full-Text Search Functions
- Mathematical Functions
- String Functions
- Type Conversion Functions
- Geo Functions
- Conditional Functions And Expressions
- System Functions
- Reserved keywords
- SQL Limitations
- Scripting
- Data management
- ILM: Manage the index lifecycle
- Overview
- Concepts
- Automate rollover
- Manage Filebeat time-based indices
- Index lifecycle actions
- Configure a lifecycle policy
- Migrate index allocation filters to node roles
- Resolve lifecycle policy execution errors
- Start and stop index lifecycle management
- Manage existing indices
- Skip rollover
- Restore a managed data stream or index
- Monitor a cluster
- Frozen indices
- Roll up or transform your data
- Set up a cluster for high availability
- Snapshot and restore
- Secure a cluster
- Overview
- Configuring security
- User authentication
- Built-in users
- Internal users
- Token-based authentication services
- Realms
- Realm chains
- Active Directory user authentication
- File-based user authentication
- LDAP user authentication
- Native user authentication
- OpenID Connect authentication
- PKI user authentication
- SAML authentication
- Kerberos authentication
- Integrating with other authentication systems
- Enabling anonymous access
- Controlling the user cache
- Configuring SAML single-sign-on on the Elastic Stack
- Configuring single sign-on to the Elastic Stack using OpenID Connect
- User authorization
- Built-in roles
- Defining roles
- Granting access to Stack Management features
- Security privileges
- Document level security
- Field level security
- Granting privileges for data streams and index aliases
- Mapping users and groups to roles
- Setting up field and document level security
- Submitting requests on behalf of other users
- Configuring authorization delegation
- Customizing roles and authorization
- Enabling audit logging
- Encrypting communications
- Restricting connections with IP filtering
- Cross cluster search, clients, and integrations
- Tutorial: Getting started with security
- Tutorial: Encrypting communications
- Troubleshooting
- Some settings are not returned via the nodes settings API
- Authorization exceptions
- Users command fails due to extra arguments
- Users are frequently locked out of Active Directory
- Certificate verification fails for curl on Mac
- SSLHandshakeException causes connections to fail
- Common SSL/TLS exceptions
- Common Kerberos exceptions
- Common SAML issues
- Internal Server Error in Kibana
- Setup-passwords command fails due to connection failure
- Failures due to relocation of the configuration files
- Limitations
- Watch for cluster and index events
- Command line tools
- How To
- Glossary of terms
- REST APIs
- API conventions
- Compact and aligned text (CAT) APIs
- cat aliases
- cat allocation
- cat anomaly detectors
- cat count
- cat data frame analytics
- cat datafeeds
- cat fielddata
- cat health
- cat indices
- cat master
- cat nodeattrs
- cat nodes
- cat pending tasks
- cat plugins
- cat recovery
- cat repositories
- cat segments
- cat shards
- cat snapshots
- cat task management
- cat templates
- cat thread pool
- cat trained model
- cat transforms
- Cluster APIs
- Cluster allocation explain
- Cluster get settings
- Cluster health
- Cluster reroute
- Cluster state
- Cluster stats
- Cluster update settings
- Nodes feature usage
- Nodes hot threads
- Nodes info
- Nodes reload secure settings
- Nodes stats
- Pending cluster tasks
- Remote cluster info
- Task management
- Voting configuration exclusions
- Cross-cluster replication APIs
- Data stream APIs
- Document APIs
- Enrich APIs
- Graph explore API
- Index APIs
- Add index alias
- Analyze
- Clear cache
- Clone index
- Close index
- Create index
- Delete index
- Delete index alias
- Delete component template
- Delete index template
- Delete index template (legacy)
- Flush
- Force merge
- Freeze index
- Get component template
- Get field mapping
- Get index
- Get index alias
- Get index settings
- Get index template
- Get index template (legacy)
- Get mapping
- Index alias exists
- Index exists
- Index recovery
- Index segments
- Index shard stores
- Index stats
- Index template exists (legacy)
- Open index
- Put index template
- Put index template (legacy)
- Put component template
- Put mapping
- Refresh
- Rollover index
- Shrink index
- Simulate index
- Simulate template
- Split index
- Synced flush
- Type exists
- Unfreeze index
- Update index alias
- Update index settings
- Resolve index
- List dangling indices
- Import dangling index
- Delete dangling index
- Index lifecycle management APIs
- Ingest APIs
- Info API
- Licensing APIs
- Machine learning anomaly detection APIs
- Add events to calendar
- Add jobs to calendar
- Close jobs
- Create jobs
- Create calendars
- Create datafeeds
- Create filters
- Delete calendars
- Delete datafeeds
- Delete events from calendar
- Delete filters
- Delete forecasts
- Delete jobs
- Delete jobs from calendar
- Delete model snapshots
- Delete expired data
- Estimate model memory
- Find file structure
- Flush jobs
- Forecast jobs
- Get buckets
- Get calendars
- Get categories
- Get datafeeds
- Get datafeed statistics
- Get influencers
- Get jobs
- Get job statistics
- Get machine learning info
- Get model snapshots
- Get overall buckets
- Get scheduled events
- Get filters
- Get records
- Open jobs
- Post data to jobs
- Preview datafeeds
- Revert model snapshots
- Set upgrade mode
- Start datafeeds
- Stop datafeeds
- Update datafeeds
- Update filters
- Update jobs
- Update model snapshots
- Machine learning data frame analytics APIs
- Create data frame analytics jobs
- Create trained models
- Update data frame analytics jobs
- Delete data frame analytics jobs
- Delete trained models
- Evaluate data frame analytics
- Explain data frame analytics
- Get data frame analytics jobs
- Get data frame analytics jobs stats
- Get trained models
- Get trained models stats
- Start data frame analytics jobs
- Stop data frame analytics jobs
- Migration APIs
- Reload search analyzers API
- Repositories metering APIs
- Rollup APIs
- Search APIs
- Searchable snapshots APIs
- Security APIs
- Authenticate
- Change passwords
- Clear cache
- Clear roles cache
- Clear privileges cache
- Clear API key cache
- Create API keys
- Create or update application privileges
- Create or update role mappings
- Create or update roles
- Create or update users
- Delegate PKI authentication
- Delete application privileges
- Delete role mappings
- Delete roles
- Delete users
- Disable users
- Enable users
- Get API key information
- Get application privileges
- Get builtin privileges
- Get role mappings
- Get roles
- Get token
- Get users
- Grant API keys
- Has privileges
- Invalidate API key
- Invalidate token
- OpenID Connect prepare authentication
- OpenID Connect authenticate
- OpenID Connect logout
- SAML prepare authentication
- SAML authenticate
- SAML logout
- SAML invalidate
- SSL certificate
- Snapshot and restore APIs
- Snapshot lifecycle management APIs
- Transform APIs
- Usage API
- Watcher APIs
- Definitions
- Migration guide
- Release notes
- Elasticsearch version 7.10.2
- Elasticsearch version 7.10.1
- Elasticsearch version 7.10.0
- Elasticsearch version 7.9.3
- Elasticsearch version 7.9.2
- Elasticsearch version 7.9.1
- Elasticsearch version 7.9.0
- Elasticsearch version 7.8.1
- Elasticsearch version 7.8.0
- Elasticsearch version 7.7.1
- Elasticsearch version 7.7.0
- Elasticsearch version 7.6.2
- Elasticsearch version 7.6.1
- Elasticsearch version 7.6.0
- Elasticsearch version 7.5.2
- Elasticsearch version 7.5.1
- Elasticsearch version 7.5.0
- Elasticsearch version 7.4.2
- Elasticsearch version 7.4.1
- Elasticsearch version 7.4.0
- Elasticsearch version 7.3.2
- Elasticsearch version 7.3.1
- Elasticsearch version 7.3.0
- Elasticsearch version 7.2.1
- Elasticsearch version 7.2.0
- Elasticsearch version 7.1.1
- Elasticsearch version 7.1.0
- Elasticsearch version 7.0.0
- Elasticsearch version 7.0.0-rc2
- Elasticsearch version 7.0.0-rc1
- Elasticsearch version 7.0.0-beta1
- Elasticsearch version 7.0.0-alpha2
- Elasticsearch version 7.0.0-alpha1
- Dependencies and versions
EQL syntax reference
editEQL syntax reference
editThis functionality is in beta and is subject to change. The design and code is less mature than official GA features and is being provided as-is with no warranties. Beta features are not subject to the support SLA of official GA features.
Basic syntax
editEQL queries require an event category and a matching condition. The where
keyword connects them.
event_category where condition
For example, the following EQL query matches process
events with a
process.name
field value of svchost.exe
:
process where process.name == "svchost.exe"
Event categories
editAn event category is a valid, indexed value of the
event category field. You can set the event category
field using the event_category_field
parameter of the EQL search API.
Match any event category
editTo match events of any category, use the any
keyword. You can also use the
any
keyword to search for documents without a event category field.
For example, the following EQL query matches any documents with a
network.protocol
field value of http
:
any where network.protocol == "http"
Escape an event category
editUse enclosing double quotes ("
) or three enclosing double quotes ("""
) to
escape event categories that:
-
Contain a special character, such as a hyphen (
-
) or dot (.
) - Contain a space
- Start with a numeral
".my.event.category" "my-event-category" "my event category" "6eventcategory" """.my.event.category""" """my-event-category""" """my event category""" """6eventcategory"""
Escape a field name
editUse enclosing enclosing backticks (`) to escape field names that:
-
Contain a hyphen (
-
) - Contain a space
- Start with a numeral
`my-field` `my field` `6myfield`
Use double backticks (``) to escape any backticks (`) in the field name.
my`field -> `my``field`
Conditions
editA condition consists of one or more criteria an event must match. You can specify and combine these criteria using the following operators. Most EQL operators are case-sensitive by default.
Comparison operators
edit< <= == : != >= >
-
<
(less than) -
Returns
true
if the value to the left of the operator is less than the value to the right. Otherwise returnsfalse
. -
<=
(less than or equal) -
Returns
true
if the value to the left of the operator is less than or equal to the value to the right. Otherwise returnsfalse
. -
==
(equal, case-sensitive) -
Returns
true
if the values to the left and right of the operator are equal. Otherwise returnsfalse
. For strings, matching is case-sensitive. -
:
(equal, case-insensitive) -
Returns
true
if strings to the left and right of the operator are equal. Otherwise returnsfalse
. Matching is case-insensitive and can only be used to compare strings.
Avoid using the ==
or :
operators to perform exact matching on
text
field values.
By default, Elasticsearch changes the values of text
fields as part of analysis. This can make finding exact matches for text
field values
difficult.
To search text
fields, consider using a query
DSL filter that contains a match
query.
-
!=
(not equal, case-sensitive) -
Returns
true
if the values to the left and right of the operator are not equal. Otherwise returnsfalse
. For strings, matching is case-sensitive. -
>=
(greater than or equal) -
Returns
true
if the value to the left of the operator is greater than or equal to the value to the right. Otherwise returnsfalse
. When comparing strings, the operator uses a case-sensitive lexicographic order. -
>
(greater than) -
Returns
true
if the value to the left of the operator is greater than the value to the right. Otherwise returnsfalse
. When comparing strings, the operator uses a case-sensitive lexicographic order.
=
is not supported as an equal operator. Use ==
or :
instead.
You cannot chain comparison operators. Instead, use a
logical operator between comparisons. For
example, foo < bar <= baz
is not supported. However, you can rewrite the
expression as foo < bar and bar <= baz
, which is supported.
You also cannot use comparison operators to compare a field to another field. This applies even if the fields are changed using a function.
Example
The following EQL query compares the process.parent_name
field
value to a static value, foo
. This comparison is supported.
However, the query also compares the process.parent.name
field value to the
process.name
field. This comparison is not supported and will return an
error for the entire query.
process where process.parent.name == "foo" and process.parent.name == process.name
Instead, you can rewrite the query to compare both the process.parent.name
and process.name
fields to static values.
process where process.parent.name == "foo" and process.name == "foo"
Logical operators
editand or not
-
and
-
Returns
true
only if the condition to the left and right both returntrue
. Otherwise returnsfalse
. -
or
-
Returns
true
if one of the conditions to the left or righttrue
. Otherwise returnsfalse
. -
not
-
Returns
true
if the condition to the right isfalse
.
Lookup operators
edituser.name in ("Administrator", "SYSTEM", "NETWORK SERVICE") user.name not in ("Administrator", "SYSTEM", "NETWORK SERVICE")
-
in
(case-sensitive) -
Returns
true
if the value is contained in the provided list. For strings, matching is case-sensitive. -
not in
(case-sensitive) -
Returns
true
if the value is not contained in the provided list. For strings, matching is case-sensitive.
Math operators
edit+ - * / %
-
+
(add) - Adds the values to the left and right of the operator.
-
-
(subtract) - Subtracts the value to the right of the operator from the value to the left.
-
*
(multiply) - Multiplies the values to the left and right of the operator.
-
/
(divide) -
Divides the value to the left of the operator by the value to the right.
If both the dividend and divisor are integers, the divide (
\
) operation rounds down any returned floating point numbers to the nearest integer. To avoid rounding, convert either the dividend or divisor to a float.Example
Theprocess.args_count
field is along
integer field containing a count of process arguments.A user might expect the following EQL query to only match events with a
process.args_count
value of4
.process where ( 4 / process.args_count ) == 1
However, the EQL query matches events with a
process.args_count
value of3
or4
.For events with a
process.args_count
value of3
, the divide operation returns a float of1.333...
, which is rounded down to1
.To match only events with a
process.args_count
value of4
, convert either the dividend or divisor to a float.The following EQL query changes the integer
4
to the equivalent float4.0
.process where ( 4.0 / process.args_count ) == 1
-
%
(modulo) - Divides the value to the left of the operator by the value to the right. Returns only the remainder.
Match any condition
editTo match events solely on event category, use the where true
condition.
For example, the following EQL query matches any file
events:
file where true
To match any event, you can combine the any
keyword with the where true
condition:
any where true
Strings
editStrings are enclosed in double quotes ("
).
"hello world"
Strings enclosed in single quotes ('
) are not supported.
Escape characters in a string
editWhen used within a string, special characters, such as a carriage return or
double quote ("
), must be escaped with a preceding backslash (\
).
"example \r of \" escaped \n characters"
Escape sequence | Literal character |
---|---|
|
A newline (linefeed) character |
|
A carriage return character |
|
A tab character |
|
A backslash ( |
|
A double quote ( |
The single quote ('
) character is reserved for future use. You
cannot use an escaped single quote (\'
) for literal strings. Use an escaped
double quote (\"
) instead.
Raw strings
editRaw strings treat special characters, such as backslashes (\
), as literal
characters. Raw strings are enclosed in three double quotes ("""
).
"""Raw string with a literal double quote " and blackslash \ included"""
A raw string cannot contain three consecutive double quotes ("""
). Instead,
use a regular string with the \"
escape sequence.
"String containing \"\"\" three double quotes"
Sequences
editYou can use EQL sequences to describe and match an ordered series of events.
Each item in a sequence is an event category and event condition,
surrounded by square brackets ([ ]
). Events are listed in ascending
chronological order, with the most recent event listed last.
sequence [ event_category_1 where condition_1 ] [ event_category_2 where condition_2 ] ...
Example
The following EQL sequence query matches this series of ordered events:
-
Start with an event with:
-
An event category of
file
-
A
file.extension
ofexe
-
An event category of
-
Followed by an event with an event category of
process
sequence [ file where file.extension == "exe" ] [ process where true ]
with maxspan
keywords
editYou can use the with maxspan
keywords to constrain a sequence to a specified
timespan. All events in a matching sequence must occur within this duration,
starting at the first event’s timestamp.
The maxspan
keyword accepts time value arguments.
sequence with maxspan=30s [ event_category_1 where condition_1 ] by field_baz [ event_category_2 where condition_2 ] by field_bar ...
Example
The following sequence query uses a maxspan
value of 15m
(15 minutes).
Events in a matching sequence must occur within 15 minutes of the first event’s
timestamp.
sequence with maxspan=15m [ file where file.extension == "exe" ] [ process where true ]
by
keyword
editYou can use the by
keyword with sequences to only match events that share the
same field values. If a field value should be shared across all events, you
can use sequence by
.
sequence by field_foo [ event_category_1 where condition_1 ] by field_baz [ event_category_2 where condition_2 ] by field_bar ...
Example
The following sequence query uses the by
keyword to constrain matching events
to:
-
Events with the same
user.name
value -
file
events with afile.path
value equal to the followingprocess
event’sprocess.path
value.
sequence [ file where file.extension == "exe" ] by user.name, file.path [ process where true ] by user.name, process.path
Because the user.name
field is shared across all events in the sequence, it
can be included using sequence by
. The following sequence is equivalent to the
prior one.
sequence by user.name [ file where file.extension == "exe" ] by file.path [ process where true ] by process.path
You can combine the sequence by
and with maxspan
keywords to constrain a
sequence by both field values and a timespan.
sequence by field_foo with maxspan=30s [ event_category_1 where condition_1 ] by field_baz [ event_category_2 where condition_2 ] by field_bar ...
Example
The following sequence query uses the sequence by
keyword and with maxspan
keywords to match only a sequence of events that:
-
Share the same
user.name
field values -
Occur within
15m
(15 minutes) of the first matching event
sequence by user.name with maxspan=15m [ file where file.extension == "exe" ] by file.path [ process where true ] by process.path
until
keyword
editYou can use the until
keyword to specify an expiration event for a sequence.
If this expiration event occurs between matching events in a sequence, the
sequence expires and is not considered a match. If the expiration event occurs
after matching events in a sequence, the sequence is still considered a
match. The expiration event is not included in the results.
sequence [ event_category_1 where condition_1 ] [ event_category_2 where condition_2 ] ... until [ event_category_3 where condition_3 ]
Example
A dataset contains the following event sequences, grouped by shared IDs:
A, B A, B, C A, C, B
The following EQL query searches the dataset for sequences containing
event A
followed by event B
. Event C
is used as an expiration event.
sequence by ID A B until C
The query matches sequences A, B
and A, B, C
but not A, C, B
.
The until
keyword can be useful when searching for process sequences in
Windows event logs.
In Windows, a process ID (PID) is unique only while a process is running. After a process terminates, its PID can be reused.
You can search for a sequence of events with the same PID value using the by
and sequence by
keywords.
Example
The following EQL query uses the sequence by
keyword to match a
sequence of events that share the same process.pid
value.
sequence by process.pid [ process where event.type == "start" and process.name == "cmd.exe" ] [ process where file.extension == "exe" ]
However, due to PID reuse, this can result in a matching sequence that
contains events across unrelated processes. To prevent false positives, you can
use the until
keyword to end matching sequences before a process termination
event.
The following EQL query uses the until
keyword to end sequences before
process
events with an event.type
of stop
. These events indicate a process
has been terminated.
sequence by process.pid [ process where event.type == "start" and process.name == "cmd.exe" ] [ process where file.extension == "exe" ] until [ process where event.type == "stop" ]
Functions
editYou can use EQL functions to convert data types, perform math, manipulate strings, and more. Most functions are case-sensitive by default.
For a list of supported functions, see Function reference.
Using functions in EQL queries can result in slower search speeds. If you often use functions to transform indexed data, you can speed up search by making these changes during indexing instead. However, that often means slower index speeds.
Example
An index contains the file.path
field. file.path
contains the full path to a
file, including the file extension.
When running EQL searches, users often use the endsWith
function with the
file.path
field to match file extensions:
file where endsWith(file.path,".exe") or endsWith(file.path,".dll")
While this works, it can be repetitive to write and can slow search speeds. To speed up search, you can do the following instead:
-
Add a new field,
file.extension
, to the index. Thefile.extension
field will contain only the file extension from thefile.path
field. -
Use an ingest pipeline containing the
grok
processor or another preprocessor tool to extract the file extension from thefile.path
field before indexing. -
Index the extracted file extension to the
file.extension
field.
These changes may slow indexing but allow for faster searches. Users
can use the file.extension
field instead of multiple endsWith
function
calls:
file where file.extension in ("exe", "dll")
We recommend testing and benchmarking any indexing changes before deploying them in production. See Tune for indexing speed and Tune for search speed.
Pipes
editEQL pipes filter, aggregate, and post-process events returned by an EQL query. You can use pipes to narrow down EQL query results or make them more specific.
Pipes are delimited using the pipe (|
) character.
event_category where condition | pipe
Example
The following EQL query uses the tail
pipe to return only the 10 most recent
events matching the query.
authentication where agent.id == 4624 | tail 10
You can pass the output of a pipe to another pipe. This lets you use multiple pipes with a single query.
For a list of supported pipes, see Pipe reference.
Limitations
editEQL does not support the following features and syntax.
Comparing fields
editYou cannot use EQL comparison operators to compare a field to another field. This applies even if the fields are changed using a function.
Array field values are not supported
editEQL does not support array field values, also known as multi-value fields. EQL searches on array field values may return inconsistent results.
EQL search on nested fields
editYou cannot use EQL to search the values of a nested
field or the
sub-fields of a nested
field. However, data streams and indices containing
nested
field mappings are otherwise supported.
Differences from Endgame EQL syntax
editElasticsearch EQL differs from the Elastic Endgame EQL syntax as follows:
-
Most operators and functions in Elasticsearch EQL are case-sensitive. For
case-insensitive equality comparisons, use the
:
operator. -
Comparisons using the
==
and!=
operators do not expand wildcard characters. For example,process_name == "cmd*.exe"
interprets*
as a literal asterisk, not a wildcard. For case-sensitive wildcard matching, use thewildcard
function. -
=
cannot be substituted for the==
operator. -
Strings enclosed in single quotes (
'
) are not supported. Enclose strings in double quotes ("
) instead. -
?"
and?'
do not indicate raw strings. Enclose raw strings in three double quotes ("""
) instead. -
Elasticsearch EQL does not support:
How sequence queries handle matches
editSequence queries don’t find all potential matches for a sequence. This approach would be too slow and costly for large event data sets. Instead, a sequence query handles pending sequence matches as a state machine:
- Each event item in the sequence query is a state in the machine.
- Only one pending sequence can be in each state at a time.
- If two pending sequences are in the same state at the same time, the most recent sequence overwrites the older one.
-
If the query includes
by
fields, the query uses a separate state machine for each uniqueby
field value.
Example
A data set contains the following process
events in ascending chronological
order:
{ "index" : { "_id": "1" } } { "user": { "name": "root" }, "process": { "name": "attrib" }, ...} { "index" : { "_id": "2" } } { "user": { "name": "root" }, "process": { "name": "attrib" }, ...} { "index" : { "_id": "3" } } { "user": { "name": "elkbee" }, "process": { "name": "bash" }, ...} { "index" : { "_id": "4" } } { "user": { "name": "root" }, "process": { "name": "bash" }, ...} { "index" : { "_id": "5" } } { "user": { "name": "root" }, "process": { "name": "bash" }, ...} { "index" : { "_id": "6" } } { "user": { "name": "elkbee" }, "process": { "name": "attrib" }, ...} { "index" : { "_id": "7" } } { "user": { "name": "root" }, "process": { "name": "attrib" }, ...} { "index" : { "_id": "8" } } { "user": { "name": "elkbee" }, "process": { "name": "bash" }, ...} { "index" : { "_id": "9" } } { "user": { "name": "root" }, "process": { "name": "cat" }, ...} { "index" : { "_id": "10" } } { "user": { "name": "elkbee" }, "process": { "name": "cat" }, ...} { "index" : { "_id": "11" } } { "user": { "name": "root" }, "process": { "name": "cat" }, ...}
An EQL sequence query searches the data set:
sequence by user.name [process where process.name == "attrib"] [process where process.name == "bash"] [process where process.name == "cat"]
The query’s event items correspond to the following states:
-
State A:
[process where process.name == "attrib"]
-
State B:
[process where process.name == "bash"]
-
Complete:
[process where process.name == "cat"]
To find matching sequences, the query uses separate state machines for each
unique user.name
value. Based on the data set, you can expect two state
machines: one for the root
user and one for elkbee
.
Pending sequence matches move through each machine’s states as follows:
{ "index" : { "_id": "1" } } { "user": { "name": "root" }, "process": { "name": "attrib" }, ...} // Creates sequence [1] in state A for the "root" user. // // +------------------------"root"------------------------+ // | +-----------+ +-----------+ +------------+ | // | | State A | | State B | | Complete | | // | +-----------+ +-----------+ +------------+ | // | | [1] | | | | | | // | +-----------+ +-----------+ +------------+ | // +------------------------------------------------------+ { "index" : { "_id": "2" } } { "user": { "name": "root" }, "process": { "name": "attrib" }, ...} // Creates sequence [2] in state A for "root", overwriting sequence [1]. // // +------------------------"root"------------------------+ // | +-----------+ +-----------+ +------------+ | // | | State A | | State B | | Complete | | // | +-----------+ +-----------+ +------------+ | // | | [2] | | | | | | // | +-----------+ +-----------+ +------------+ | // +------------------------------------------------------+ { "index" : { "_id": "3" } } { "user": { "name": "elkbee" }, "process": { "name": "bash" }, ...} // Nothing happens. The "elkbee" user has no pending sequence to move // from state A to state B. // // +-----------------------"elkbee"-----------------------+ // | +-----------+ +-----------+ +------------+ | // | | State A | | State B | | Complete | | // | +-----------+ +-----------+ +------------+ | // | | | | | | | | // | +-----------+ +-----------+ +------------+ | // +------------------------------------------------------+ { "index" : { "_id": "4" } } { "user": { "name": "root" }, "process": { "name": "bash" }, ...} // Sequence [2] moves out of state A for "root". // State B for "root" now contains [2, 4]. // State A for "root" is empty. // // +------------------------"root"------------------------+ // | +-----------+ +-----------+ +------------+ | // | | State A | | State B | | Complete | | // | +-----------+ --> +-----------+ +------------+ | // | | | | [2, 4] | | | | // | +-----------+ +-----------+ +------------+ | // +------------------------------------------------------+ { "index" : { "_id": "5" } } { "user": { "name": "root" }, "process": { "name": "bash" }, ...} // Nothing happens. State A is empty for "root". // // +------------------------"root"------------------------+ // | +-----------+ +-----------+ +------------+ | // | | State A | | State B | | Complete | | // | +-----------+ +-----------+ +------------+ | // | | | | [2, 4] | | | | // | +-----------+ +-----------+ +------------+ | // +------------------------------------------------------+ { "index" : { "_id": "6" } } { "user": { "name": "elkbee" }, "process": { "name": "attrib" }, ...} // Creates sequence [6] in state A for "elkbee". // // +-----------------------"elkbee"-----------------------+ // | +-----------+ +-----------+ +------------+ | // | | State A | | State B | | Complete | | // | +-----------+ +-----------+ +------------+ | // | | [6] | | | | | | // | +-----------+ +-----------+ +------------+ | // +------------------------------------------------------+ { "index" : { "_id": "7" } } { "user": { "name": "root" }, "process": { "name": "attrib" }, ...} // Creates sequence [7] in state A for "root". // Sequence [2, 4] remains in state B for "root". // // +------------------------"root"------------------------+ // | +-----------+ +-----------+ +------------+ | // | | State A | | State B | | Complete | | // | +-----------+ +-----------+ +------------+ | // | | [7] | | [2, 4] | | | | // | +-----------+ +-----------+ +------------+ | // +------------------------------------------------------+ { "index" : { "_id": "8" } } { "user": { "name": "elkbee" }, "process": { "name": "bash" }, ...} // Sequence [6, 8] moves to state B for "elkbee". // State A for "elkbee" is now empty. // // +-----------------------"elkbee"-----------------------+ // | +-----------+ +-----------+ +------------+ | // | | State A | | State B | | Complete | | // | +-----------+ --> +-----------+ +------------+ | // | | | | [6, 8] | | | | // | +-----------+ +-----------+ +------------+ | // +------------------------------------------------------+ { "index" : { "_id": "9" } } { "user": { "name": "root" }, "process": { "name": "cat" }, ...} // Sequence [2, 4, 9] is complete for "root". // State B for "root" is now empty. // Sequence [7] remains in state A. // // +------------------------"root"------------------------+ // | +-----------+ +-----------+ +------------+ | // | | State A | | State B | | Complete | | // | +-----------+ +-----------+ --> +------------+ | // | | [7] | | | | [2, 4, 9] | // | +-----------+ +-----------+ +------------+ | // +------------------------------------------------------+ { "index" : { "_id": "10" } } { "user": { "name": "elkbee" }, "process": { "name": "cat" }, ...} // Sequence [6, 8, 10] is complete for "elkbee". // State A and B for "elkbee" are now empty. // // +-----------------------"elkbee"-----------------------+ // | +-----------+ +-----------+ +------------+ | // | | State A | | State B | | Complete | | // | +-----------+ +-----------+ --> +------------+ | // | | | | | | [6, 8, 10] | // | +-----------+ +-----------+ +------------+ | // +------------------------------------------------------+ { "index" : { "_id": "11" } } { "user": { "name": "root" }, "process": { "name": "cat" }, ...} // Nothing happens. // The machines for "root" and "elkbee" remain the same. // // +------------------------"root"------------------------+ // | +-----------+ +-----------+ +------------+ | // | | State A | | State B | | Complete | | // | +-----------+ +-----------+ +------------+ | // | | [7] | | | | [2, 4, 9] | // | +-----------+ +-----------+ +------------+ | // +------------------------------------------------------+ // // +-----------------------"elkbee"-----------------------+ // | +-----------+ +-----------+ +------------+ | // | | State A | | State B | | Complete | | // | +-----------+ +-----------+ +------------+ | // | | | | | | [6, 8, 10] | // | +-----------+ +-----------+ +------------+ | // +------------------------------------------------------+
On this page
- Basic syntax
- Event categories
- Match any event category
- Escape an event category
- Escape a field name
- Conditions
- Comparison operators
- Logical operators
- Lookup operators
- Math operators
- Match any condition
- Strings
- Escape characters in a string
- Raw strings
- Sequences
with maxspan
keywordsby
keyworduntil
keyword- Functions
- Pipes
- Limitations
- Comparing fields
- Array field values are not supported
- EQL search on nested fields
- Differences from Endgame EQL syntax
- How sequence queries handle matches