@@ -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,34 +39,56 @@ 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": [
62
67
{
63
68
"_index": "sec_logs",
64
69
"_id": "1",
65
70
"_score": null,
71
+ "_source": {
72
+ "@timestamp": "2020-12-06T11:04:05.000Z",
73
+ "agent": {
74
+ "id": "8a4f500d"
75
+ },
76
+ "event": {
77
+ "category": "process"
78
+ },
79
+ "process": {
80
+ "name": "cmd.exe",
81
+ "path": "C:\\Windows\\System32\\cmd.exe"
82
+ }
83
+ },
84
+ "sort": [
85
+ 1607252645000
86
+ ]
87
+ },
88
+ {
89
+ "_index": "sec_logs",
90
+ "_id": "3",
91
+ "_score": null,
66
92
"_source": {
67
93
"@timestamp": "2020-12-07T11:06:07.000Z",
68
94
"agent": {
@@ -76,31 +102,32 @@ The API returns the following response containing the matching event:
76
102
"path": "C:\\Windows\\System32\\cmd.exe"
77
103
}
78
104
},
79
- "sort" : [1607339167000]
105
+ "sort": [
106
+ 1607339167000
107
+ ]
80
108
}
81
109
]
82
110
}
83
111
}
84
112
----
85
- // TESTRESPONSE[s/"took": 3 /"took": $body.took/]
113
+ // TESTRESPONSE[s/"took": 60 /"took": $body.took/]
86
114
87
115
[discrete]
88
- [[eql-search-specify-event-type -field]]
89
- === Specify an event type field
116
+ [[eql-search-specify-event-category -field]]
117
+ === Specify an event category field
90
118
91
- The EQL search API uses `event.category` as the required <<eql-required-fields,event
92
- category field>> by default. You can use the `event_category_field` parameter to specify
93
- another event category field.
119
+ The EQL search API uses `event.category` as the required
120
+ <<eql-required-fields,event category field>> by default. You can use the
121
+ `event_category_field` parameter to specify another event category field.
94
122
95
- For example, the following request specifies `file.type` as the event type
123
+ For example, the following request specifies `file.type` as the event category
96
124
field.
97
125
98
126
[source,console]
99
127
----
100
128
GET sec_logs/_eql/search
101
129
{
102
- "event_category_field": "file.type",
103
- "timestamp_field": "@timestamp",
130
+ "event_category_field": "file.type",
104
131
"query": """
105
132
file where agent.id == "8a4f500d"
106
133
"""
@@ -123,7 +150,6 @@ timestamp field.
123
150
GET sec_logs/_eql/search
124
151
{
125
152
"timestamp_field": "file.accessed",
126
- "event_category_field": "event.category",
127
153
"query": """
128
154
file where (file.size > 1 and file.type == "file")
129
155
"""
@@ -147,8 +173,6 @@ filtered documents.
147
173
----
148
174
GET sec_logs/_eql/search
149
175
{
150
- "event_category_field": "event.category",
151
- "timestamp_field": "@timestamp",
152
176
"filter": {
153
177
"range" : {
154
178
"file.size" : {
0 commit comments