- Elasticsearch Guide: other versions:
- What is Elasticsearch?
- What’s new in 7.9
- 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
- ILM: Manage the index lifecycle
- 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
- Alerting on cluster and index events
- Command line tools
- How To
- Glossary of terms
- REST APIs
- API conventions
- 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 shards
- cat segments
- 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
- 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
- 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 API
- Ingest APIs
- Info API
- Licensing APIs
- Machine learning anomaly detection APIs
- Add events to calendar
- Add jobs to calendar
- Close jobs
- Create jobs
- Create calendar
- Create datafeeds
- Create filter
- Delete calendar
- Delete datafeeds
- Delete events from calendar
- Delete filter
- Delete forecast
- 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 filter
- Update jobs
- Update model snapshots
- Machine learning data frame analytics APIs
- Create data frame analytics jobs
- Create trained model
- Update data frame analytics jobs
- Delete data frame analytics jobs
- Delete trained model
- Evaluate data frame analytics
- Explain data frame analytics API
- Get data frame analytics jobs
- Get data frame analytics jobs stats
- Get trained model
- Get trained model stats
- Start data frame analytics jobs
- Stop data frame analytics jobs
- Migration APIs
- Reload search analyzers
- Rollup APIs
- Search APIs
- Security APIs
- Authenticate
- Change passwords
- Clear cache
- Clear roles cache
- Clear privileges 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 API
- OpenID Connect authenticate API
- OpenID Connect logout API
- SAML prepare authentication API
- SAML authenticate API
- SAML logout API
- SAML invalidate API
- SSL certificate
- Snapshot and restore APIs
- Snapshot lifecycle management API
- Transform APIs
- Usage API
- Watcher APIs
- Definitions
- Breaking changes
- Release notes
- 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
EQL search API
editEQL search API
editThis functionality is in technical preview and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.
Returns search results for an Event Query Language (EQL) query.
In Elasticsearch, EQL assumes each document in a data stream or index corresponds to an event.
GET /my-index-000001/_eql/search { "query": """ process where process.name == "regsvr32.exe" """ }
Path parameters
edit-
<target>
-
(Required, string) Comma-separated list of data streams, indices, or index aliases used to limit the request. Accepts wildcard (
*
) expressions.To search all data streams and indices in a cluster, use
_all
or*
.
Query parameters
edit-
allow_no_indices
-
(Optional, Boolean) If
false
, the request returns an error when a wildcard expression, index alias, or_all
value targets only missing or closed indices.Defaults to
false
. -
expand_wildcards
-
(Optional, string) Controls what kind of indices that wildcard expressions can expand to. Multiple values are accepted when separated by a comma, as in
open,hidden
. Valid values are:-
all
- Expand to open and closed indices, including hidden indices.
-
open
- Expand only to open indices.
-
closed
- Expand only to closed indices.
-
hidden
-
Expansion of wildcards will include hidden indices.
Must be combined with
open
,closed
, or both. -
none
- Wildcard expressions are not accepted.
Defaults to
open
. -
-
ignore_unavailable
-
(Optional, Boolean) If
false
, the request returns an error if it targets a missing or closed index. Defaults tofalse
. -
keep_alive
-
(Optional, time value) Period for which the search and its results are stored on the cluster. Defaults to
5d
(five days).When this period expires, the search and its results are deleted, even if the search is still ongoing.
If the
keep_on_completion
parameter isfalse
, Elasticsearch only stores async searches that do not complete within the period set by thewait_for_completion_timeout
parameter, regardless of this value.You can also specify this value using the
keep_alive
request body parameter. If both parameters are specified, only the query parameter is used. -
keep_on_completion
-
(Optional, Boolean) If
true
, the search and its results are stored on the cluster.If
false
, the search and its results are stored on the cluster only if the request does not complete during the period set by thewait_for_completion_timeout
parameter. Defaults tofalse
.You can also specify this value using the
keep_on_completion
request body parameter. If both parameters are specified, only the query parameter is used. -
wait_for_completion_timeout
-
(Optional, time value) Timeout duration to wait for the request to finish. Defaults to no timeout, meaning the request waits for complete search results.
If this parameter is specified and the request completes during this period, complete search results are returned.
If the request does not complete during this period, the search becomes an async search.
You can also specify this value using the
wait_for_completion_timeout
request body parameter. If both parameters are specified, only the query parameter is used.
Request body
edit-
case_sensitive
-
(Optional, Boolean)
If
true
, matching for the EQL query is case sensitive. Defaults tofalse
. -
event_category_field
-
(Required*, string) Field containing the event classification, such as
process
,file
, ornetwork
.Defaults to
event.category
, as defined in the Elastic Common Schema (ECS). If a data stream or index does not contain theevent.category
field, this value is required.The event category field is typically mapped as a field type in the
keyword
family. -
fetch_size
-
(Optional, integer) Maximum number of events to search at a time for sequence queries. Defaults to
1000
.This value must be greater than
2
but cannot exceed the value of theindex.max_result_window
setting, which defaults to10000
.Internally, a sequence query fetches and paginates sets of events to search for matches. This parameter controls the size of those sets. This parameter does not limit the total number of events searched or the number of matching events returned.
A greater
fetch_size
value often increases search speed but uses more memory. -
filter
- (Optional, query DSL object) Query, written in query DSL, used to filter the events on which the EQL query runs.
-
keep_alive
-
(Optional, time value) Period for which the search and its results are stored on the cluster. Defaults to
5d
(five days).When this period expires, the search and its results are deleted, even if the search is still ongoing.
If the
keep_on_completion
parameter isfalse
, Elasticsearch only stores async searches that do not complete within the period set by thewait_for_completion_timeout
parameter, regardless of this value.You can also specify this value using the
keep_alive
query parameter. If both parameters are specified, only the query parameter is used.
-
keep_on_completion
-
(Optional, Boolean) If
true
, the search and its results are stored on the cluster.If
false
, the search and its results are stored on the cluster only if the request does not complete during the period set by thewait_for_completion_timeout
parameter. Defaults tofalse
.You can also specify this value using the
keep_on_completion
query parameter. If both parameters are specified, only the query parameter is used.
-
query
-
(Required, string) EQL query you wish to run.
This parameter supports a subset of EQL syntax. See Unsupported syntax.
-
size
-
(Optional, integer or float) For basic queries, the maximum number of matching events to return.
For sequence queries, the maximum number of matching sequences to return.
Defaults to
10
. This value must be greater than0
.You cannot use pipes, such as
head
ortail
, to exceed this value.
-
tiebreaker_field
- (Optional, string) Field used to sort hits with the same timestamp in ascending, lexicographic order. See Specify a sort tiebreaker.
-
timestamp_field
-
(Required*, string) Field containing event timestamp.
Defaults to
@timestamp
, as defined in the Elastic Common Schema (ECS). If a data stream or index does not contain the@timestamp
field, this value is required.Events in the API response are sorted by this field’s value, converted to milliseconds since the Unix epoch, in ascending order.
The timestamp field should be mapped as a
date
. Thedate_nanos
field type is not supported.
-
wait_for_completion_timeout
-
(Optional, time value) Timeout duration to wait for the request to finish. Defaults to no timeout, meaning the request waits for complete search results.
If this parameter is specified and the request completes during this period, complete search results are returned.
If the request does not complete during this period, the search becomes an async search.
You can also specify this value using the
wait_for_completion_timeout
query parameter. If both parameters are specified, only the query parameter is used.
Response body
edit-
id
-
(string) Identifier for the search.
This search ID is only provided if one of the following conditions is met:
-
A search request does not return complete results during the
wait_for_completion_timeout
parameter’s timeout period, becoming an async search. -
The search request’s
keep_on_completion
parameter istrue
.
You can use this ID with the get async EQL search API to get the current status and available results for the search.
-
A search request does not return complete results during the
-
is_partial
-
(Boolean)
If
true
, the response does not contain complete search results. -
is_running
-
(Boolean) If
true
, the search request is still executing.If this parameter and the
is_partial
parameter aretrue
, the search is an ongoing async search. If thekeep_alive
period does not pass, the complete search results will be available when the search completes.If
is_partial
istrue
butis_running
isfalse
, the search returned partial results due to a failure. Only some shards returned results or the node coordinating the search failed. -
took
-
(integer) Milliseconds it took Elasticsearch to execute the request.
This value is calculated by measuring the time elapsed between receipt of a request on the coordinating node and the time at which the coordinating node is ready to send the response.
Took time includes:
- Communication time between the coordinating node and data nodes
-
Time the request spends in the
search
thread pool, queued for execution - Actual execution time
Took time does not include:
- Time needed to send the request to Elasticsearch
- Time needed to serialize the JSON response
- Time needed to send the response to a client
-
timed_out
-
(Boolean)
If
true
, the request timed out before completion. -
hits
-
(object) Contains matching events and sequences. Also contains related metadata.
Properties of
hits
-
total
-
(object) Metadata about the number of matching events or sequences.
Properties of
total
-
value
-
(integer) For basic queries, the total number of matching events.
For sequence queries, the total number of matching sequences.
-
relation
-
(string) Indicates whether the number of events or sequences returned is accurate or a lower bound.
Returned values are:
-
eq
- Accurate
-
gte
- Lower bound, including returned events or sequences
-
-
-
sequences
-
(array of objects) Contains event sequences matching the query. Each object represents a matching sequence. This parameter is only returned for EQL queries containing a sequence.
Properties of
sequences
objects-
join_keys
-
(array of values)
Shared field values used to constrain matches in the sequence. These are defined
using the
by
keyword in the EQL query syntax. -
events
-
(array of objects) Contains events matching the query. Each object represents a matching event.
Properties of
events
objects-
_index
- (string) Name of the index containing the event.
-
_id
- (string) Unique identifier for the event. This ID is only unique within the index.
-
_version
- (integer) Version of the document (event). This version is incremented each time the document is updated.
-
_seq_no
-
(integer) Sequence number assigned to the document (event).
Sequence numbers are used to ensure an older version of a document doesn’t overwrite a newer version. See Optimistic concurrency control.
-
_primary_term
- (integer) Primary term assigned to the document. See Optimistic concurrency control.
-
_score
- (float) Positive 32-bit floating point number used to determine the relevance of the event. See Relevance scores.
-
_source
- (object) Original JSON body passed for the event at index time.
-
-
-
events
-
(array of objects) Contains events matching the query. Each object represents a matching event.
Properties of
events
objects-
_index
- (string) Name of the index containing the event.
-
_id
- (string) (string) Unique identifier for the event. This ID is only unique within the index.
-
_score
- (float) Positive 32-bit floating point number used to determine the relevance of the event. See Relevance scores.
-
_source
- (object) Original JSON body passed for the event at index time.
-
-
Examples
editBasic query example
editThe following EQL search request searches for events with an event.category
of
process
that meet the following conditions:
-
A
process.name
ofcmd.exe
-
An
process.pid
other than2013
GET /my-index-000001/_eql/search { "query": """ process where (process.name == "cmd.exe" and process.pid != 2013) """ }
The API returns the following response. Matching events in the hits.events
property are sorted by timestamp, converted
to milliseconds since the Unix epoch,
in ascending order.
If two or more events share the same timestamp, the
tiebreaker_field
field is used to sort
the events in ascending, lexicographic order.
{ "is_partial": false, "is_running": false, "took": 6, "timed_out": false, "hits": { "total": { "value": 2, "relation": "eq" }, "events": [ { "_index": "my-index-000001", "_type": "_doc", "_id": "babI3XMBI9IjHuIqU0S_", "_score": null, "_source": { "@timestamp": "2099-12-06T11:04:05.000Z", "event": { "category": "process", "id": "edwCRnyD", "sequence": 1 }, "process": { "pid": 2012, "name": "cmd.exe", "executable": "C:\\Windows\\System32\\cmd.exe" } } }, { "_index": "my-index-000001", "_type": "_doc", "_id": "b6bI3XMBI9IjHuIqU0S_", "_score": null, "_source": { "@timestamp": "2099-12-07T11:06:07.000Z", "event": { "category": "process", "id": "cMyt5SZ2", "sequence": 3 }, "process": { "pid": 2012, "name": "cmd.exe", "executable": "C:\\Windows\\System32\\cmd.exe" } } } ] } }
Sequence query example
editThe following EQL search request matches a sequence of events that:
-
Start with an event with:
-
An
event.category
offile
-
A
file.name
ofcmd.exe
-
An
process.pid
other than2013
-
An
-
Followed by an event with:
-
An
event.category
ofprocess
-
A
process.executable
that contains the substringregsvr32
-
An
These events must also share the same process.pid
value.
GET /my-index-000001/_eql/search { "query": """ sequence by process.pid [ file where file.name == "cmd.exe" and process.pid != 2013 ] [ process where stringContains(process.executable, "regsvr32") ] """ }
The API returns the following response. Matching sequences are included in the
hits.sequences
property. The hits.sequences.join_keys
property contains the
shared process.pid
value for each matching event.
{ "is_partial": false, "is_running": false, "took": 6, "timed_out": false, "hits": { "total": { "value": 1, "relation": "eq" }, "sequences": [ { "join_keys": [ 2012 ], "events": [ { "_index": "my-index-000001", "_type": "_doc", "_id": "AtOJ4UjUBAAx3XR5kcCM", "_version": 1, "_seq_no": 1, "_primary_term": 1, "_score": null, "_source": { "@timestamp": "2099-12-06T11:04:07.000Z", "event": { "category": "file", "id": "dGCHwoeS", "sequence": 2 }, "file": { "accessed": "2099-12-07T11:07:08.000Z", "name": "cmd.exe", "path": "C:\\Windows\\System32\\cmd.exe", "type": "file", "size": 16384 }, "process": { "pid": 2012, "name": "cmd.exe", "executable": "C:\\Windows\\System32\\cmd.exe" } } }, { "_index": "my-index-000001", "_type": "_doc", "_id": "OQmfCaduce8zoHT93o4H", "_version": 1, "_seq_no": 3, "_primary_term": 1, "_score": null, "_source": { "@timestamp": "2099-12-07T11:07:09.000Z", "event": { "category": "process", "id": "aR3NWVOs", "sequence": 4 }, "process": { "pid": 2012, "name": "regsvr32.exe", "command_line": "regsvr32.exe /s /u /i:https://...RegSvr32.sct scrobj.dll", "executable": "C:\\Windows\\System32\\regsvr32.exe" } } } ] } ] } }
On this page