grok.asciidoc 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. [discrete]
  2. [[esql-grok]]
  3. === `GROK`
  4. `GROK` enables you to <<esql-process-data-with-dissect-and-grok,extract
  5. structured data out of a string>>.
  6. **Syntax**
  7. [source,esql]
  8. ----
  9. GROK input "pattern"
  10. ----
  11. *Parameters*
  12. `input`::
  13. The column that contains the string you want to structure. If the column has
  14. multiple values, `GROK` will process each value.
  15. `pattern`::
  16. A grok pattern.
  17. *Description*
  18. `GROK` enables you to <<esql-process-data-with-dissect-and-grok,extract
  19. structured data out of a string>>. `GROK` matches the string against patterns,
  20. based on regular expressions, and extracts the specified patterns as columns.
  21. Refer to <<esql-process-data-with-grok>> for the syntax of grok patterns.
  22. *Examples*
  23. // tag::examples[]
  24. The following example parses a string that contains a timestamp, an IP address,
  25. an email address, and a number:
  26. [source.merge.styled,esql]
  27. ----
  28. include::{esql-specs}/docs.csv-spec[tag=basicGrok]
  29. ----
  30. [%header.monospaced.styled,format=dsv,separator=|]
  31. |===
  32. include::{esql-specs}/docs.csv-spec[tag=basicGrok-result]
  33. |===
  34. By default, `GROK` outputs keyword string columns. `int` and `float` types can
  35. be converted by appending `:type` to the semantics in the pattern. For example
  36. `{NUMBER:num:int}`:
  37. [source.merge.styled,esql]
  38. ----
  39. include::{esql-specs}/docs.csv-spec[tag=grokWithConversionSuffix]
  40. ----
  41. [%header.monospaced.styled,format=dsv,separator=|]
  42. |===
  43. include::{esql-specs}/docs.csv-spec[tag=grokWithConversionSuffix-result]
  44. |===
  45. For other type conversions, use <<esql-type-conversion-functions>>:
  46. [source.merge.styled,esql]
  47. ----
  48. include::{esql-specs}/docs.csv-spec[tag=grokWithToDatetime]
  49. ----
  50. [%header.monospaced.styled,format=dsv,separator=|]
  51. |===
  52. include::{esql-specs}/docs.csv-spec[tag=grokWithToDatetime-result]
  53. |===
  54. // end::examples[]