Test a Grok pattern Added in 8.13.0

POST /_text_structure/test_grok_pattern

Test a Grok pattern on one or more lines of text. The API indicates whether the lines match the pattern together with the offsets and lengths of the matched substrings.

Query parameters

  • The mode of compatibility with ECS compliant Grok patterns (disabled or v1, default: disabled).

application/json

Body Required

  • grok_pattern string Required
  • text array[string] Required

    Lines of text to run the Grok pattern on.

Responses

  • 200 application/json
    Hide response attribute Show response attribute object
    • matches array[object] Required
      Hide matches attributes Show matches attributes object
      • matched boolean Required
      • fields object
        Hide fields attribute Show fields attribute object
        • * array[object] Additional properties
          Hide * attributes Show * attributes object
POST /_text_structure/test_grok_pattern
curl \
 -X POST http://api.example.com/_text_structure/test_grok_pattern \
 -H "Content-Type: application/json" \
 -d '{"grok_pattern":"string","text":["string"]}'
Request examples
{
  "grok_pattern": "string",
  "text": [
    "string"
  ]
}
Response examples (200)
{
  "matches": [
    {
      "matched": true,
      "fields": {
        "additionalProperty1": [
          {
            "match": "string",
            "offset": 42.0,
            "length": 42.0
          }
        ],
        "additionalProperty2": [
          {
            "match": "string",
            "offset": 42.0,
            "length": 42.0
          }
        ]
      }
    }
  ]
}