search.asciidoc 1.8 KB

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