grok.asciidoc 1.6 KB

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