@@ -17,10 +17,14 @@ The following <<docs-bulk,bulk API>> request adds some example log data to the
17
17
----
18
18
PUT sec_logs/_bulk?refresh
19
19
{"index":{"_index" : "sec_logs", "_id" : "1"}}
20
- { "@timestamp": "2020-12-07T11:06:07 .000Z", "agent": { "id": "8a4f500d" }, "event": { "category": "process" }, "process": { "name": "cmd.exe", "path": "C:\\Windows\\System32\\cmd.exe" } }
20
+ { "@timestamp": "2020-12-06T11:04:05 .000Z", "agent": { "id": "8a4f500d" }, "event": { "category": "process" }, "process": { "name": "cmd.exe", "path": "C:\\Windows\\System32\\cmd.exe" } }
21
21
{"index":{"_index" : "sec_logs", "_id" : "2"}}
22
- { "@timestamp": "2020-12-07T11:07:08 .000Z", "agent": { "id": "8a4f500d" }, "event": { "category": "file" }, "file": { "accessed": "2020-12-07T11:07:08.000Z", "name": "cmd.exe", "path": "C:\\Windows\\System32\\cmd.exe", "type": "file", "size": 16384 }, "process": { "name": "cmd.exe", "path": "C:\\Windows\\System32\\cmd.exe" } }
22
+ { "@timestamp": "2020-12-06T11:04:07 .000Z", "agent": { "id": "8a4f500d" }, "event": { "category": "file" }, "file": { "accessed": "2020-12-07T11:07:08.000Z", "name": "cmd.exe", "path": "C:\\Windows\\System32\\cmd.exe", "type": "file", "size": 16384 }, "process": { "name": "cmd.exe", "path": "C:\\Windows\\System32\\cmd.exe" } }
23
23
{"index":{"_index" : "sec_logs", "_id" : "3"}}
24
+ { "@timestamp": "2020-12-07T11:06:07.000Z", "agent": { "id": "8a4f500d" }, "event": { "category": "process" }, "process": { "name": "cmd.exe", "path": "C:\\Windows\\System32\\cmd.exe" } }
25
+ {"index":{"_index" : "sec_logs", "_id" : "4"}}
26
+ { "@timestamp": "2020-12-07T11:07:08.000Z", "agent": { "id": "8a4f500d" }, "event": { "category": "file" }, "file": { "accessed": "2020-12-07T11:07:08.000Z", "name": "cmd.exe", "path": "C:\\Windows\\System32\\cmd.exe", "type": "file", "size": 16384 }, "process": { "name": "cmd.exe", "path": "C:\\Windows\\System32\\cmd.exe" } }
27
+ {"index":{"_index" : "sec_logs", "_id" : "5"}}
24
28
{ "@timestamp": "2020-12-07T11:07:09.000Z", "agent": { "id": "8a4f500d" }, "event": { "category": "process" }, "process": { "name": "regsvr32.exe", "path": "C:\\Windows\\System32\\regsvr32.exe" } }
25
29
----
26
30
// TESTSETUP
@@ -35,27 +39,28 @@ specified in the `query` parameter. The EQL query matches events with an
35
39
----
36
40
GET sec_logs/_eql/search
37
41
{
38
- "event_category_field": "event.category",
39
- "timestamp_field": "@timestamp",
40
42
"query": """
41
43
process where process.name == "cmd.exe"
42
44
"""
43
45
}
44
46
----
45
47
46
48
Because the `sec_log` index follows the ECS, you don't need to specify the
47
- timestamp field. The request uses the `@timestamp` field by default.
49
+ required <<eql-required-fields,event category or timestamp>> fields. The request
50
+ uses the `event.category` and `@timestamp` fields by default.
48
51
49
- The API returns the following response containing the matching event:
52
+ The API returns the following response containing the matching events. Events
53
+ in the response are sorted by timestamp, converted to milliseconds since the
54
+ https://en.wikipedia.org/wiki/Unix_time[Unix epoch], in ascending order.
50
55
51
56
[source,console-result]
52
57
----
53
58
{
54
- "took": 3 ,
59
+ "took": 60 ,
55
60
"timed_out": false,
56
61
"hits": {
57
62
"total": {
58
- "value": 1 ,
63
+ "value": 2 ,
59
64
"relation": "eq"
60
65
},
61
66
"events": [
@@ -64,6 +69,27 @@ The API returns the following response containing the matching event:
64
69
"_type": "_doc",
65
70
"_id": "1",
66
71
"_score": null,
72
+ "_source": {
73
+ "@timestamp": "2020-12-06T11:04:05.000Z",
74
+ "agent": {
75
+ "id": "8a4f500d"
76
+ },
77
+ "event": {
78
+ "category": "process"
79
+ },
80
+ "process": {
81
+ "name": "cmd.exe",
82
+ "path": "C:\\Windows\\System32\\cmd.exe"
83
+ }
84
+ },
85
+ "sort": [
86
+ 1607252645000
87
+ ]
88
+ },
89
+ {
90
+ "_index": "sec_logs",
91
+ "_id": "3",
92
+ "_score": null,
67
93
"_source": {
68
94
"@timestamp": "2020-12-07T11:06:07.000Z",
69
95
"agent": {
@@ -77,31 +103,32 @@ The API returns the following response containing the matching event:
77
103
"path": "C:\\Windows\\System32\\cmd.exe"
78
104
}
79
105
},
80
- "sort" : [1607339167000]
106
+ "sort": [
107
+ 1607339167000
108
+ ]
81
109
}
82
110
]
83
111
}
84
112
}
85
113
----
86
- // TESTRESPONSE[s/"took": 3 /"took": $body.took/]
114
+ // TESTRESPONSE[s/"took": 60 /"took": $body.took/]
87
115
88
116
[discrete]
89
- [[eql-search-specify-event-type -field]]
90
- === Specify an event type field
117
+ [[eql-search-specify-event-category -field]]
118
+ === Specify an event category field
91
119
92
- The EQL search API uses `event.category` as the required <<eql-required-fields,event
93
- category field>> by default. You can use the `event_category_field` parameter to specify
94
- another event category field.
120
+ The EQL search API uses `event.category` as the required
121
+ <<eql-required-fields,event category field>> by default. You can use the
122
+ `event_category_field` parameter to specify another event category field.
95
123
96
- For example, the following request specifies `file.type` as the event type
124
+ For example, the following request specifies `file.type` as the event category
97
125
field.
98
126
99
127
[source,console]
100
128
----
101
129
GET sec_logs/_eql/search
102
130
{
103
- "event_category_field": "file.type",
104
- "timestamp_field": "@timestamp",
131
+ "event_category_field": "file.type",
105
132
"query": """
106
133
file where agent.id == "8a4f500d"
107
134
"""
@@ -124,7 +151,6 @@ timestamp field.
124
151
GET sec_logs/_eql/search
125
152
{
126
153
"timestamp_field": "file.accessed",
127
- "event_category_field": "event.category",
128
154
"query": """
129
155
file where (file.size > 1 and file.type == "file")
130
156
"""
@@ -148,8 +174,6 @@ filtered documents.
148
174
----
149
175
GET sec_logs/_eql/search
150
176
{
151
- "event_category_field": "event.category",
152
- "timestamp_field": "@timestamp",
153
177
"filter": {
154
178
"range" : {
155
179
"file.size" : {
0 commit comments