Class Grok

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

public final class Grok extends Object
  • Field Details

    • ECS_COMPATIBILITY_MODES

      public static final String[] ECS_COMPATIBILITY_MODES
  • Constructor Details

  • Method Details

    • toRegex

      protected String toRegex(String grokPattern)
      converts a grok expression into a named regex expression
      Returns:
      named regex expression
    • 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
    • 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.
    • getBuiltinPatterns

      public static Map<String,String> getBuiltinPatterns(boolean ecsCompatibility)
      Load built-in patterns.
    • getBuiltinPatterns

      public static Map<String,String> getBuiltinPatterns(String ecsCompatibility)
    • isValidEcsCompatibilityMode

      public static boolean isValidEcsCompatibilityMode(String ecsCompatibility)