|
| 1 | +[role="xpack"] |
| 2 | +[testenv="basic"] |
| 3 | +[[eql-search]] |
| 4 | +== Run an EQL search |
| 5 | + |
| 6 | +experimental::[] |
| 7 | + |
| 8 | +To start using EQL in {es}, first ensure your event data meets |
| 9 | +<<eql-requirements,EQL requirements>>. Then ingest or add the data to an {es} |
| 10 | +index. |
| 11 | + |
| 12 | +The following <<docs-bulk,bulk API>> request adds some example log data to the |
| 13 | +`sec_logs` index. This log data follows the {ecs-ref}[Elastic Common Schema |
| 14 | +(ECS)]. |
| 15 | + |
| 16 | +[source,console] |
| 17 | +---- |
| 18 | +PUT sec_logs/_bulk?refresh |
| 19 | +{"index":{"_index" : "sec_logs"}} |
| 20 | +{ "@timestamp": "2020-12-07T11:06:07.000Z", "agent": { "id": "8a4f500d" }, "event": { "category": "process" }, "process": { "name": "cmd.exe", "path": "C:\\Windows\\System32\\cmd.exe" } } |
| 21 | +{"index":{"_index" : "sec_logs"}} |
| 22 | +{ "@timestamp": "2020-12-07T11:07:08.000Z", "agent": { "id": "8a4f500d" }, "event": { "category": "image_load" }, "file": { "name": "cmd.exe", "path": "C:\\Windows\\System32\\cmd.exe" }, "process": { "name": "cmd.exe", "path": "C:\\Windows\\System32\\cmd.exe" } } |
| 23 | +{"index":{"_index" : "sec_logs"}} |
| 24 | +{ "@timestamp": "2020-12-07T11:07:09.000Z", "agent": { "id": "8a4f500d" }, "event": { "category": "process" }, "process": { "name": "regsvr32.exe", "path": "C:\\Windows\\System32\\regsvr32.exe" } } |
| 25 | +---- |
| 26 | + |
| 27 | +You can now use the EQL search API to search this index using an EQL query. |
| 28 | + |
| 29 | +The following request searches the `sec_logs` index using the EQL query |
| 30 | +specified in the `rule` parameter. The EQL query matches events with an |
| 31 | +`event.category` of `process` that have a `process.name` of `cmd.exe`. |
| 32 | + |
| 33 | +[source,console] |
| 34 | +---- |
| 35 | +GET sec_logs/_eql/search |
| 36 | +{ |
| 37 | + "rule": """ |
| 38 | + process where process.name == "cmd.exe" |
| 39 | + """ |
| 40 | +} |
| 41 | +---- |
| 42 | +// TEST[continued] |
| 43 | + |
| 44 | +Because the `sec_log` index follows the ECS, you don't need to specify the |
| 45 | +event type or timestamp fields. The request uses the `event.category` and |
| 46 | +`@timestamp` fields by default. |
0 commit comments