2020-04-24 15:36:01 -04:00
|
|
|
[role="xpack"]
|
|
|
|
[testenv="basic"]
|
|
|
|
|
|
|
|
[[eql-search-api]]
|
|
|
|
=== EQL search API
|
|
|
|
++++
|
|
|
|
<titleabbrev>EQL search</titleabbrev>
|
|
|
|
++++
|
|
|
|
|
2020-07-13 09:04:15 -04:00
|
|
|
experimental::[]
|
2020-04-24 15:36:01 -04:00
|
|
|
|
|
|
|
Returns search results for an <<eql,Event Query Language (EQL)>> query.
|
|
|
|
|
2020-07-13 09:03:55 -04:00
|
|
|
In {es}, EQL assumes each document in a data stream or index corresponds to an
|
|
|
|
event.
|
2020-05-05 15:59:19 -04:00
|
|
|
|
2020-04-24 15:36:01 -04:00
|
|
|
[source,console]
|
|
|
|
----
|
2020-08-05 11:25:18 -04:00
|
|
|
GET /my-index-000001/_eql/search
|
2020-04-24 15:36:01 -04:00
|
|
|
{
|
|
|
|
"query": """
|
2020-09-22 12:09:38 -04:00
|
|
|
process where process.name == "regsvr32.exe"
|
2020-04-24 15:36:01 -04:00
|
|
|
"""
|
|
|
|
}
|
|
|
|
----
|
2020-08-05 11:25:18 -04:00
|
|
|
// TEST[setup:sec_logs]
|
2020-04-24 15:36:01 -04:00
|
|
|
|
|
|
|
[[eql-search-api-request]]
|
|
|
|
==== {api-request-title}
|
|
|
|
|
2020-07-13 09:03:55 -04:00
|
|
|
`GET /<target>/_eql/search`
|
2020-04-24 15:36:01 -04:00
|
|
|
|
2020-07-13 09:03:55 -04:00
|
|
|
`POST /<target>/_eql/search`
|
2020-04-24 15:36:01 -04:00
|
|
|
|
|
|
|
[[eql-search-api-prereqs]]
|
|
|
|
==== {api-prereq-title}
|
|
|
|
|
2020-08-05 11:25:18 -04:00
|
|
|
See <<eql-required-fields>>.
|
2020-04-24 15:36:01 -04:00
|
|
|
|
|
|
|
[[eql-search-api-limitations]]
|
|
|
|
===== Limitations
|
|
|
|
|
2020-08-05 11:25:18 -04:00
|
|
|
See <<eql-syntax-limitations,EQL limitations>>.
|
2020-04-24 15:36:01 -04:00
|
|
|
|
|
|
|
[[eql-search-api-path-params]]
|
|
|
|
==== {api-path-parms-title}
|
|
|
|
|
2020-07-13 09:03:55 -04:00
|
|
|
`<target>`::
|
2020-04-24 15:36:01 -04:00
|
|
|
(Required, string)
|
2020-07-13 09:03:55 -04:00
|
|
|
Comma-separated list of data streams, indices, or <<indices-aliases,index
|
|
|
|
aliases>> used to limit the request. Accepts wildcard (`*`) expressions.
|
2020-04-24 15:36:01 -04:00
|
|
|
+
|
2020-07-13 09:03:55 -04:00
|
|
|
To search all data streams and indices in a cluster, use
|
|
|
|
`_all` or `*`.
|
2020-04-24 15:36:01 -04:00
|
|
|
|
|
|
|
[[eql-search-api-query-params]]
|
|
|
|
==== {api-query-parms-title}
|
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
|
2020-04-24 15:36:01 -04:00
|
|
|
+
|
|
|
|
Defaults to `false`.
|
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
|
2020-04-24 15:36:01 -04:00
|
|
|
+
|
|
|
|
Defaults to `open`.
|
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
|
2020-04-24 15:36:01 -04:00
|
|
|
|
2020-06-25 14:11:57 -04:00
|
|
|
`keep_alive`::
|
|
|
|
+
|
|
|
|
--
|
|
|
|
(Optional, <<time-units,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 <<eql-search-api-keep-on-completion,`keep_on_completion`>> parameter is
|
2020-06-30 09:36:08 -04:00
|
|
|
`false`, {es} only stores <<eql-search-async,async searches>> that do not
|
2020-06-25 14:11:57 -04:00
|
|
|
complete within the period set by the
|
|
|
|
<<eql-search-api-wait-for-completion-timeout,`wait_for_completion_timeout`>>
|
|
|
|
parameter, regardless of this value.
|
|
|
|
|
|
|
|
[IMPORTANT]
|
|
|
|
====
|
|
|
|
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 the
|
|
|
|
<<eql-search-api-wait-for-completion-timeout,`wait_for_completion_timeout`>>
|
|
|
|
parameter. Defaults to `false`.
|
|
|
|
|
|
|
|
[IMPORTANT]
|
|
|
|
====
|
|
|
|
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-units,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
|
|
|
|
<<eql-search-async,async search>>.
|
|
|
|
|
|
|
|
[IMPORTANT]
|
|
|
|
====
|
|
|
|
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.
|
|
|
|
====
|
|
|
|
--
|
|
|
|
|
2020-04-24 15:36:01 -04:00
|
|
|
[[eql-search-api-request-body]]
|
|
|
|
==== {api-request-body-title}
|
|
|
|
|
2020-05-15 11:47:19 -04:00
|
|
|
`case_sensitive`::
|
|
|
|
(Optional, boolean)
|
|
|
|
If `true`, matching for the <<eql-search-api-request-query-param,EQL query>> is
|
|
|
|
case sensitive. Defaults to `false`.
|
|
|
|
|
2020-04-24 15:36:01 -04:00
|
|
|
`event_category_field`::
|
|
|
|
(Required*, string)
|
|
|
|
Field containing the event classification, such as `process`, `file`, or
|
|
|
|
`network`.
|
|
|
|
+
|
|
|
|
Defaults to `event.category`, as defined in the {ecs-ref}/ecs-event.html[Elastic
|
2020-07-13 09:03:55 -04:00
|
|
|
Common Schema (ECS)]. If a data stream or index does not contain the
|
|
|
|
`event.category` field, this value is required.
|
2020-08-05 11:25:18 -04:00
|
|
|
+
|
2020-09-14 09:51:34 -04:00
|
|
|
The event category field is typically mapped as a field type in the
|
|
|
|
<<keyword,`keyword`>> family.
|
2020-04-24 15:36:01 -04:00
|
|
|
|
2020-07-08 12:22:57 -04:00
|
|
|
`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 the
|
|
|
|
<<index-max-result-window,`index.max_result_window`>> setting, which defaults to
|
|
|
|
`10000`.
|
|
|
|
+
|
|
|
|
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.
|
|
|
|
|
2020-05-12 13:49:22 -04:00
|
|
|
`filter`::
|
|
|
|
(Optional, <<query-dsl,query DSL object>>)
|
|
|
|
Query, written in query DSL, used to filter the events on which the EQL query
|
|
|
|
runs.
|
|
|
|
|
2020-06-25 14:11:57 -04:00
|
|
|
`keep_alive`::
|
|
|
|
+
|
|
|
|
--
|
|
|
|
(Optional, <<time-units,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 <<eql-search-api-keep-on-completion,`keep_on_completion`>> parameter is
|
2020-06-30 09:36:08 -04:00
|
|
|
`false`, {es} only stores <<eql-search-async,async searches>> that do not
|
2020-06-25 14:11:57 -04:00
|
|
|
complete within the period set by the
|
|
|
|
<<eql-search-api-wait-for-completion-timeout,`wait_for_completion_timeout`>>
|
|
|
|
parameter, regardless of this value.
|
|
|
|
|
|
|
|
[IMPORTANT]
|
|
|
|
====
|
|
|
|
You can also specify this value using the `keep_alive` query parameter.
|
|
|
|
If both parameters are specified, only the query parameter is used.
|
|
|
|
====
|
|
|
|
--
|
|
|
|
|
|
|
|
[[eql-search-api-keep-on-completion]]
|
|
|
|
`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 the
|
|
|
|
<<eql-search-api-wait-for-completion-timeout,`wait_for_completion_timeout`>>
|
|
|
|
parameter. Defaults to `false`.
|
|
|
|
|
|
|
|
[IMPORTANT]
|
|
|
|
====
|
|
|
|
You can also specify this value using the `keep_on_completion` query parameter.
|
|
|
|
If both parameters are specified, only the query parameter is used.
|
|
|
|
====
|
|
|
|
--
|
|
|
|
|
2020-05-15 11:47:19 -04:00
|
|
|
[[eql-search-api-request-query-param]]
|
2020-05-12 13:49:22 -04:00
|
|
|
`query`::
|
|
|
|
(Required, string)
|
|
|
|
<<eql-syntax,EQL>> query you wish to run.
|
|
|
|
+
|
|
|
|
IMPORTANT: This parameter supports a subset of EQL syntax. See
|
|
|
|
<<eql-unsupported-syntax>>.
|
|
|
|
|
|
|
|
`size`::
|
|
|
|
(Optional, integer or float)
|
2020-06-10 10:08:46 -04:00
|
|
|
For <<eql-basic-syntax,basic queries>>, the maximum number of matching events to
|
|
|
|
return.
|
|
|
|
+
|
|
|
|
For <<eql-sequences,sequence queries>>, the maximum number of matching sequences
|
|
|
|
to return.
|
|
|
|
+
|
2020-07-08 12:22:57 -04:00
|
|
|
Defaults to `10`. This value must be greater than `0`.
|
|
|
|
+
|
|
|
|
NOTE: You cannot use <<eql-pipe-ref,pipes>>, such as `head` or `tail`, to exceed
|
|
|
|
this value.
|
2020-06-26 09:25:24 -04:00
|
|
|
|
|
|
|
[[eql-search-api-tiebreaker-field]]
|
|
|
|
`tiebreaker_field`::
|
|
|
|
(Optional, string)
|
|
|
|
Field used to sort events with the same
|
|
|
|
<<eql-search-api-timestamp-field,timestamp field>> value. Defaults to
|
|
|
|
`event.sequence`, as defined in the {ecs-ref}/ecs-event.html[Elastic Common
|
|
|
|
Schema (ECS)].
|
|
|
|
+
|
|
|
|
By default, matching events in the search response are sorted by timestamp,
|
2020-08-17 11:27:04 -04:00
|
|
|
converted to milliseconds since the {wikipedia}/Unix_time[Unix
|
2020-06-26 09:25:24 -04:00
|
|
|
epoch], in ascending order. If two or more events share the same timestamp, this
|
|
|
|
field is used to sort the events in ascending, lexicographic order.
|
2020-05-12 13:49:22 -04:00
|
|
|
|
2020-04-24 15:36:01 -04:00
|
|
|
[[eql-search-api-timestamp-field]]
|
|
|
|
`timestamp_field`::
|
|
|
|
+
|
|
|
|
--
|
|
|
|
(Required*, string)
|
|
|
|
Field containing event timestamp.
|
|
|
|
|
|
|
|
Defaults to `@timestamp`, as defined in the
|
2020-07-13 09:03:55 -04:00
|
|
|
{ecs-ref}/ecs-event.html[Elastic Common Schema (ECS)]. If a data stream or index
|
|
|
|
does not contain the `@timestamp` field, this value is required.
|
2020-04-24 15:36:01 -04:00
|
|
|
|
|
|
|
Events in the API response are sorted by this field's value, converted to
|
2020-08-17 11:27:04 -04:00
|
|
|
milliseconds since the {wikipedia}/Unix_time[Unix epoch], in
|
2020-04-24 15:36:01 -04:00
|
|
|
ascending order.
|
2020-08-05 11:25:18 -04:00
|
|
|
|
|
|
|
The timestamp field is typically mapped as a <<date,`date`>> or
|
|
|
|
<<date_nanos,`date_nanos`>> field.
|
2020-04-24 15:36:01 -04:00
|
|
|
--
|
|
|
|
|
2020-06-25 14:11:57 -04:00
|
|
|
[[eql-search-api-wait-for-completion-timeout]]
|
|
|
|
`wait_for_completion_timeout`::
|
|
|
|
+
|
|
|
|
--
|
|
|
|
(Optional, <<time-units,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
|
|
|
|
<<eql-search-async,async search>>.
|
|
|
|
|
|
|
|
[IMPORTANT]
|
|
|
|
====
|
|
|
|
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.
|
|
|
|
====
|
|
|
|
--
|
|
|
|
|
2020-05-05 15:59:19 -04:00
|
|
|
[role="child_attributes"]
|
2020-04-24 15:36:01 -04:00
|
|
|
[[eql-search-api-response-body]]
|
|
|
|
==== {api-response-body-title}
|
|
|
|
|
2020-06-25 14:11:57 -04:00
|
|
|
[[eql-search-api-response-body-search-id]]
|
|
|
|
`id`::
|
|
|
|
+
|
|
|
|
--
|
2020-07-15 17:23:48 -04:00
|
|
|
(string)
|
2020-06-25 14:11:57 -04:00
|
|
|
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
|
|
|
|
<<eql-search-api-wait-for-completion-timeout,`wait_for_completion_timeout`>>
|
|
|
|
parameter's timeout period, becoming an <<eql-search-async,async search>>.
|
|
|
|
|
|
|
|
* The search request's <<eql-search-api-keep-on-completion,`keep_on_completion`>>
|
|
|
|
parameter is `true`.
|
|
|
|
|
|
|
|
You can use this ID with the <<get-async-eql-search-api,get async EQL search
|
|
|
|
API>> to get the current status and available results for the search.
|
|
|
|
--
|
|
|
|
|
|
|
|
`is_partial`::
|
|
|
|
(boolean)
|
|
|
|
If `true`, the response does not contain complete search results.
|
|
|
|
|
|
|
|
`is_running`::
|
|
|
|
+
|
|
|
|
--
|
|
|
|
(boolean)
|
|
|
|
If `true`, the search request is still executing.
|
|
|
|
|
|
|
|
[IMPORTANT]
|
|
|
|
====
|
|
|
|
If this parameter and the `is_partial` parameter are `true`, the search is an
|
|
|
|
<<eql-search-async,ongoing async search>>. If the `keep_alive` period does not
|
|
|
|
pass, the complete search results will be available when the search completes.
|
|
|
|
|
|
|
|
If `is_partial` is `true` but `is_running` is `false`, the search returned
|
|
|
|
partial results due to a failure. Only some shards returned results or the node
|
|
|
|
coordinating the search failed.
|
|
|
|
====
|
|
|
|
--
|
|
|
|
|
2020-04-24 15:36:01 -04:00
|
|
|
`took`::
|
|
|
|
+
|
|
|
|
--
|
|
|
|
(integer)
|
|
|
|
Milliseconds it took {es} 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
|
2020-05-05 15:59:19 -04:00
|
|
|
* Time the request spends in the `search` <<modules-threadpool,thread pool>>,
|
2020-04-24 15:36:01 -04:00
|
|
|
queued for execution
|
|
|
|
* Actual execution time
|
|
|
|
|
|
|
|
Took time does *not* include:
|
|
|
|
|
|
|
|
* Time needed to send the request to {es}
|
|
|
|
* Time needed to serialize the JSON response
|
|
|
|
* Time needed to send the response to a client
|
|
|
|
--
|
|
|
|
|
|
|
|
`timed_out`::
|
|
|
|
(boolean)
|
2020-05-05 15:59:19 -04:00
|
|
|
If `true`, the request timed out before completion.
|
2020-04-24 15:36:01 -04:00
|
|
|
|
|
|
|
`hits`::
|
|
|
|
(object)
|
2020-06-02 09:38:00 -04:00
|
|
|
Contains matching events and sequences. Also contains related metadata.
|
2020-05-05 15:59:19 -04:00
|
|
|
+
|
|
|
|
.Properties of `hits`
|
|
|
|
[%collapsible%open]
|
|
|
|
====
|
2020-04-24 15:36:01 -04:00
|
|
|
|
2020-05-05 15:59:19 -04:00
|
|
|
`total`::
|
|
|
|
(object)
|
2020-06-02 09:38:00 -04:00
|
|
|
Metadata about the number of matching events or sequences.
|
2020-05-05 15:59:19 -04:00
|
|
|
+
|
|
|
|
.Properties of `total`
|
|
|
|
[%collapsible%open]
|
|
|
|
=====
|
|
|
|
|
|
|
|
`value`::
|
2020-04-24 15:36:01 -04:00
|
|
|
(integer)
|
2020-06-02 09:38:00 -04:00
|
|
|
For <<eql-basic-syntax,basic queries>>, the total number of matching events.
|
|
|
|
+
|
|
|
|
For <<eql-sequences,sequence queries>>, the total number of matching sequences.
|
2020-04-24 15:36:01 -04:00
|
|
|
|
2020-05-05 15:59:19 -04:00
|
|
|
`relation`::
|
2020-04-24 15:36:01 -04:00
|
|
|
+
|
|
|
|
--
|
|
|
|
(string)
|
2020-06-02 09:38:00 -04:00
|
|
|
Indicates whether the number of events or sequences returned is accurate or a
|
|
|
|
lower bound.
|
2020-04-24 15:36:01 -04:00
|
|
|
|
|
|
|
Returned values are:
|
|
|
|
|
|
|
|
`eq`::: Accurate
|
2020-06-02 09:38:00 -04:00
|
|
|
`gte`::: Lower bound, including returned events or sequences
|
2020-04-24 15:36:01 -04:00
|
|
|
--
|
2020-05-05 15:59:19 -04:00
|
|
|
=====
|
2020-04-24 15:36:01 -04:00
|
|
|
|
2020-05-14 11:51:40 -04:00
|
|
|
`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 <<eql-sequences,sequence>>.
|
|
|
|
+
|
|
|
|
.Properties of `sequences` objects
|
|
|
|
[%collapsible%open]
|
|
|
|
=====
|
|
|
|
`join_keys`::
|
2020-08-18 12:37:15 -04:00
|
|
|
(array of values)
|
2020-05-14 11:51:40 -04:00
|
|
|
Shared field values used to constrain matches in the sequence. These are defined
|
|
|
|
using the <<eql-sequences,`by` keyword>> in the EQL query syntax.
|
|
|
|
|
2020-05-05 15:59:19 -04:00
|
|
|
`events`::
|
2020-04-24 15:36:01 -04:00
|
|
|
(array of objects)
|
2020-05-14 11:51:40 -04:00
|
|
|
Contains events matching the query. Each object represents a
|
2020-05-05 15:59:19 -04:00
|
|
|
matching event.
|
|
|
|
+
|
|
|
|
.Properties of `events` objects
|
|
|
|
[%collapsible%open]
|
2020-05-14 11:51:40 -04:00
|
|
|
======
|
|
|
|
`_index`::
|
|
|
|
(string)
|
|
|
|
Name of the index containing the event.
|
|
|
|
|
|
|
|
`_id`::
|
|
|
|
(string)
|
|
|
|
Unique identifier for the event.
|
|
|
|
This ID is only unique within the index.
|
|
|
|
|
|
|
|
`_source`::
|
|
|
|
(object)
|
|
|
|
Original JSON body passed for the event at index time.
|
|
|
|
======
|
2020-05-05 15:59:19 -04:00
|
|
|
=====
|
2020-04-24 15:36:01 -04:00
|
|
|
|
2020-05-14 11:51:40 -04:00
|
|
|
[[eql-search-api-response-events]]
|
|
|
|
`events`::
|
|
|
|
(array of objects)
|
|
|
|
Contains events matching the query. Each object represents a
|
|
|
|
matching event.
|
|
|
|
+
|
|
|
|
.Properties of `events` objects
|
|
|
|
[%collapsible%open]
|
|
|
|
=====
|
2020-05-05 15:59:19 -04:00
|
|
|
`_index`::
|
2020-04-24 15:36:01 -04:00
|
|
|
(string)
|
2020-05-14 11:51:40 -04:00
|
|
|
Name of the index containing the event.
|
2020-04-24 15:36:01 -04:00
|
|
|
|
2020-05-05 15:59:19 -04:00
|
|
|
`_id`::
|
|
|
|
(string)
|
2020-04-24 15:36:01 -04:00
|
|
|
(string)
|
2020-05-14 11:51:40 -04:00
|
|
|
Unique identifier for the event.
|
|
|
|
This ID is only unique within the index.
|
2020-04-24 15:36:01 -04:00
|
|
|
|
2020-05-05 15:59:19 -04:00
|
|
|
`_source`::
|
2020-04-24 15:36:01 -04:00
|
|
|
(object)
|
2020-05-05 15:59:19 -04:00
|
|
|
Original JSON body passed for the event at index time.
|
|
|
|
=====
|
|
|
|
====
|
2020-04-24 15:36:01 -04:00
|
|
|
|
|
|
|
[[eql-search-api-example]]
|
|
|
|
==== {api-examples-title}
|
|
|
|
|
2020-05-14 11:51:40 -04:00
|
|
|
[[eql-search-api-basic-query-ex]]
|
2020-05-18 16:28:38 -04:00
|
|
|
===== Basic query example
|
2020-05-14 11:51:40 -04:00
|
|
|
|
2020-04-24 15:36:01 -04:00
|
|
|
The following EQL search request searches for events with an `event.category` of
|
2020-08-11 12:01:31 -04:00
|
|
|
`process` that meet the following conditions:
|
2020-04-24 15:36:01 -04:00
|
|
|
|
2020-08-11 12:01:31 -04:00
|
|
|
* A `process.name` of `cmd.exe`
|
2020-08-05 11:25:18 -04:00
|
|
|
* An `process.pid` other than `2013`
|
2020-04-24 15:36:01 -04:00
|
|
|
|
|
|
|
[source,console]
|
|
|
|
----
|
2020-08-05 11:25:18 -04:00
|
|
|
GET /my-index-000001/_eql/search
|
2020-04-24 15:36:01 -04:00
|
|
|
{
|
|
|
|
"query": """
|
2020-08-11 12:01:31 -04:00
|
|
|
process where (process.name == "cmd.exe" and process.pid != 2013)
|
2020-04-24 15:36:01 -04:00
|
|
|
"""
|
|
|
|
}
|
|
|
|
----
|
2020-08-05 11:25:18 -04:00
|
|
|
// TEST[setup:sec_logs]
|
2020-04-24 15:36:01 -04:00
|
|
|
|
2020-05-14 11:51:40 -04:00
|
|
|
The API returns the following response. Matching events in the `hits.events`
|
|
|
|
property are sorted by <<eql-search-api-timestamp-field,timestamp>>, converted
|
2020-08-17 11:27:04 -04:00
|
|
|
to milliseconds since the {wikipedia}/Unix_time[Unix epoch],
|
2020-05-14 11:51:40 -04:00
|
|
|
in ascending order.
|
2020-04-24 15:36:01 -04:00
|
|
|
|
2020-06-26 09:25:24 -04:00
|
|
|
If two or more events share the same timestamp, the
|
|
|
|
<<eql-search-api-tiebreaker-field,`tiebreaker_field`>> field is used to sort
|
|
|
|
the events in ascending, lexicographic order.
|
|
|
|
|
2020-04-24 15:36:01 -04:00
|
|
|
[source,console-result]
|
|
|
|
----
|
|
|
|
{
|
2020-06-25 14:11:57 -04:00
|
|
|
"is_partial": false,
|
|
|
|
"is_running": false,
|
2020-04-24 15:36:01 -04:00
|
|
|
"took": 6,
|
|
|
|
"timed_out": false,
|
|
|
|
"hits": {
|
|
|
|
"total": {
|
|
|
|
"value": 2,
|
|
|
|
"relation": "eq"
|
|
|
|
},
|
|
|
|
"events": [
|
|
|
|
{
|
2020-08-05 11:25:18 -04:00
|
|
|
"_index": "my-index-000001",
|
2020-08-11 12:01:31 -04:00
|
|
|
"_id": "babI3XMBI9IjHuIqU0S_",
|
2020-04-24 15:36:01 -04:00
|
|
|
"_source": {
|
2020-08-11 12:01:31 -04:00
|
|
|
"@timestamp": "2099-12-06T11:04:05.000Z",
|
2020-04-24 15:36:01 -04:00
|
|
|
"event": {
|
2020-08-11 12:01:31 -04:00
|
|
|
"category": "process",
|
|
|
|
"id": "edwCRnyD",
|
|
|
|
"sequence": 1
|
2020-04-24 15:36:01 -04:00
|
|
|
},
|
|
|
|
"process": {
|
2020-08-11 12:01:31 -04:00
|
|
|
"pid": 2012,
|
2020-04-24 15:36:01 -04:00
|
|
|
"name": "cmd.exe",
|
2020-08-11 12:01:31 -04:00
|
|
|
"executable": "C:\\Windows\\System32\\cmd.exe"
|
2020-04-24 15:36:01 -04:00
|
|
|
}
|
2020-07-14 16:26:25 -04:00
|
|
|
}
|
2020-04-24 15:36:01 -04:00
|
|
|
},
|
|
|
|
{
|
2020-08-05 11:25:18 -04:00
|
|
|
"_index": "my-index-000001",
|
2020-08-11 12:01:31 -04:00
|
|
|
"_id": "b6bI3XMBI9IjHuIqU0S_",
|
2020-04-24 15:36:01 -04:00
|
|
|
"_source": {
|
2020-08-11 12:01:31 -04:00
|
|
|
"@timestamp": "2099-12-07T11:06:07.000Z",
|
2020-04-24 15:36:01 -04:00
|
|
|
"event": {
|
2020-08-11 12:01:31 -04:00
|
|
|
"category": "process",
|
|
|
|
"id": "cMyt5SZ2",
|
|
|
|
"sequence": 3
|
2020-04-24 15:36:01 -04:00
|
|
|
},
|
|
|
|
"process": {
|
2020-08-11 12:01:31 -04:00
|
|
|
"pid": 2012,
|
2020-04-24 15:36:01 -04:00
|
|
|
"name": "cmd.exe",
|
2020-08-11 12:01:31 -04:00
|
|
|
"executable": "C:\\Windows\\System32\\cmd.exe"
|
2020-04-24 15:36:01 -04:00
|
|
|
}
|
2020-07-14 16:26:25 -04:00
|
|
|
}
|
2020-04-24 15:36:01 -04:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
2020-05-14 11:51:40 -04:00
|
|
|
// TESTRESPONSE[s/"took": 6/"took": $body.took/]
|
2020-08-11 12:01:31 -04:00
|
|
|
// TESTRESPONSE[s/"_id": "babI3XMBI9IjHuIqU0S_"/"_id": $body.hits.events.0._id/]
|
|
|
|
// TESTRESPONSE[s/"_id": "b6bI3XMBI9IjHuIqU0S_"/"_id": $body.hits.events.1._id/]
|
2020-05-14 11:51:40 -04:00
|
|
|
|
|
|
|
[[eql-search-api-sequence-ex]]
|
2020-05-18 16:28:38 -04:00
|
|
|
===== Sequence query example
|
2020-05-14 11:51:40 -04:00
|
|
|
|
|
|
|
The following EQL search request matches a <<eql-sequences,sequence>> of events
|
|
|
|
that:
|
|
|
|
|
|
|
|
. Start with an event with:
|
|
|
|
+
|
|
|
|
--
|
|
|
|
* An `event.category` of `file`
|
|
|
|
* A `file.name` of `cmd.exe`
|
2020-08-05 11:25:18 -04:00
|
|
|
* An `process.pid` other than `2013`
|
2020-05-14 11:51:40 -04:00
|
|
|
--
|
|
|
|
. Followed by an event with:
|
|
|
|
+
|
|
|
|
--
|
|
|
|
* An `event.category` of `process`
|
2020-07-15 17:23:48 -04:00
|
|
|
* A `process.executable` that contains the substring `regsvr32`
|
2020-05-14 11:51:40 -04:00
|
|
|
--
|
|
|
|
|
2020-08-05 11:25:18 -04:00
|
|
|
These events must also share the same `process.pid` value.
|
2020-05-14 11:51:40 -04:00
|
|
|
|
|
|
|
[source,console]
|
|
|
|
----
|
2020-08-05 11:25:18 -04:00
|
|
|
GET /my-index-000001/_eql/search
|
2020-05-14 11:51:40 -04:00
|
|
|
{
|
|
|
|
"query": """
|
2020-08-05 11:25:18 -04:00
|
|
|
sequence by process.pid
|
|
|
|
[ file where file.name == "cmd.exe" and process.pid != 2013 ]
|
2020-07-15 17:23:48 -04:00
|
|
|
[ process where stringContains(process.executable, "regsvr32") ]
|
2020-05-14 11:51:40 -04:00
|
|
|
"""
|
|
|
|
}
|
|
|
|
----
|
2020-08-05 11:25:18 -04:00
|
|
|
// TEST[setup:sec_logs]
|
2020-05-14 11:51:40 -04:00
|
|
|
|
2020-08-05 11:25:18 -04:00
|
|
|
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.
|
2020-06-26 09:25:24 -04:00
|
|
|
|
2020-05-14 11:51:40 -04:00
|
|
|
[source,console-result]
|
|
|
|
----
|
|
|
|
{
|
2020-06-25 14:11:57 -04:00
|
|
|
"is_partial": false,
|
|
|
|
"is_running": false,
|
2020-05-14 11:51:40 -04:00
|
|
|
"took": 6,
|
|
|
|
"timed_out": false,
|
|
|
|
"hits": {
|
|
|
|
"total": {
|
|
|
|
"value": 1,
|
|
|
|
"relation": "eq"
|
|
|
|
},
|
|
|
|
"sequences": [
|
|
|
|
{
|
|
|
|
"join_keys": [
|
2020-08-18 12:37:15 -04:00
|
|
|
2012
|
2020-05-14 11:51:40 -04:00
|
|
|
],
|
|
|
|
"events": [
|
|
|
|
{
|
2020-08-05 11:25:18 -04:00
|
|
|
"_index": "my-index-000001",
|
2020-07-15 17:23:48 -04:00
|
|
|
"_id": "AtOJ4UjUBAAx3XR5kcCM",
|
2020-05-14 11:51:40 -04:00
|
|
|
"_source": {
|
2020-08-11 12:01:31 -04:00
|
|
|
"@timestamp": "2099-12-06T11:04:07.000Z",
|
2020-05-14 11:51:40 -04:00
|
|
|
"event": {
|
2020-06-26 09:25:24 -04:00
|
|
|
"category": "file",
|
2020-08-11 12:01:31 -04:00
|
|
|
"id": "dGCHwoeS",
|
|
|
|
"sequence": 2
|
2020-05-14 11:51:40 -04:00
|
|
|
},
|
|
|
|
"file": {
|
2020-08-11 12:01:31 -04:00
|
|
|
"accessed": "2099-12-07T11:07:08.000Z",
|
2020-05-14 11:51:40 -04:00
|
|
|
"name": "cmd.exe",
|
|
|
|
"path": "C:\\Windows\\System32\\cmd.exe",
|
|
|
|
"type": "file",
|
|
|
|
"size": 16384
|
|
|
|
},
|
2020-08-11 12:01:31 -04:00
|
|
|
"process": {
|
|
|
|
"pid": 2012,
|
2020-05-14 11:51:40 -04:00
|
|
|
"name": "cmd.exe",
|
2020-08-11 12:01:31 -04:00
|
|
|
"executable": "C:\\Windows\\System32\\cmd.exe"
|
2020-05-14 11:51:40 -04:00
|
|
|
}
|
2020-07-14 16:26:25 -04:00
|
|
|
}
|
2020-05-14 11:51:40 -04:00
|
|
|
},
|
|
|
|
{
|
2020-08-05 11:25:18 -04:00
|
|
|
"_index": "my-index-000001",
|
2020-08-11 12:01:31 -04:00
|
|
|
"_id": "OQmfCaduce8zoHT93o4H",
|
2020-05-14 11:51:40 -04:00
|
|
|
"_source": {
|
2020-08-11 12:01:31 -04:00
|
|
|
"@timestamp": "2099-12-07T11:07:09.000Z",
|
2020-05-14 11:51:40 -04:00
|
|
|
"event": {
|
2020-06-26 09:25:24 -04:00
|
|
|
"category": "process",
|
|
|
|
"id": "aR3NWVOs",
|
2020-08-11 12:01:31 -04:00
|
|
|
"sequence": 4
|
2020-05-14 11:51:40 -04:00
|
|
|
},
|
2020-08-11 12:01:31 -04:00
|
|
|
"process": {
|
|
|
|
"pid": 2012,
|
2020-05-14 11:51:40 -04:00
|
|
|
"name": "regsvr32.exe",
|
2020-08-11 12:01:31 -04:00
|
|
|
"command_line": "regsvr32.exe /s /u /i:https://...RegSvr32.sct scrobj.dll",
|
|
|
|
"executable": "C:\\Windows\\System32\\regsvr32.exe"
|
2020-05-14 11:51:40 -04:00
|
|
|
}
|
2020-07-14 16:26:25 -04:00
|
|
|
}
|
2020-05-14 11:51:40 -04:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
|
|
|
// TESTRESPONSE[s/"took": 6/"took": $body.took/]
|
2020-07-15 17:23:48 -04:00
|
|
|
// TESTRESPONSE[s/"_id": "AtOJ4UjUBAAx3XR5kcCM"/"_id": $body.hits.sequences.0.events.0._id/]
|
2020-08-11 12:01:31 -04:00
|
|
|
// TESTRESPONSE[s/"_id": "OQmfCaduce8zoHT93o4H"/"_id": $body.hits.sequences.0.events.1._id/]
|