Class Grok

java.lang.Object
org.elasticsearch.grok.Grok

public final class Grok extends Object
  • Constructor Details

  • Method Details

    • match

      public boolean match(String text)
      Checks whether a specific text matches the defined grok expression.
      Parameters:
      text - the string to match
      Returns:
      true if grok expression matches text or there is a timeout, false otherwise.
    • captures

      public Map<String,Object> captures(String text)
      Matches and returns any named captures.
      Parameters:
      text - the text to match and extract values from.
      Returns:
      a map containing field names and their respective coerced values that matched or null if the pattern didn't match
    • captureRanges

      public Map<String,Object> captureRanges(String text)
      Matches and returns the ranges of any named captures.
      Parameters:
      text - the text to match and extract values from.
      Returns:
      a map containing field names and their respective ranges that matched or null if the pattern didn't match
    • match

      public boolean match(byte[] utf8Bytes, int offset, int length, GrokCaptureExtracter extracter)
      Matches and collects any named captures.
      Parameters:
      utf8Bytes - array containing the text to match against encoded in utf-8
      offset - offset utf8Bytes of the start of the text
      length - length of the text to match
      extracter - collector for captures. GrokCaptureConfig.nativeExtracter(org.elasticsearch.grok.GrokCaptureConfig.NativeExtracterMap<T>) can build these.
      Returns:
      true if there was a match, false otherwise
      Throws:
      RuntimeException - if there was a timeout
    • captureConfig

      public List<GrokCaptureConfig> captureConfig()
      The list of values that this Grok can capture.
    • getCompiledExpression

      public org.joni.Regex getCompiledExpression()