Class GrokCaptureConfig

java.lang.Object
org.elasticsearch.grok.GrokCaptureConfig

public final class GrokCaptureConfig extends Object
Configuration for a value that Grok can capture.
  • Method Details

    • name

      public String name()
      The name defined for the field in the pattern.
    • type

      public GrokCaptureType type()
      The type defined for the field in the pattern.
    • objectExtracter

      public GrokCaptureExtracter objectExtracter(Consumer<Object> emit)
      Build a GrokCaptureExtracter that will call emit when it extracts text, boxed if the "native" representation is primitive type. Extracters returned from this method are stateless and can be reused.
    • nativeExtracter

      public <T> T nativeExtracter(GrokCaptureConfig.NativeExtracterMap<T> map)
      Build an extract that has access to the "native" type of the extracter match. This means that patterns like %{NUMBER:bytes:float} has access to an actual float. Extracters returned from this method should be stateless stateless and can be reused. Pathological implementations of the map parameter could violate this, but the caller should take care to stay sane.

      While the goal is to produce a GrokCaptureExtracter that provides a primitive, the caller can produce whatever type-safe constructs it needs and return them from this method. Thus the <T> in the type signature.

      Type Parameters:
      T - The type of the result.
      Parameters:
      map - Collection of handlers for each native type. Only one method will be called but well behaved implementers are stateless.
      Returns:
      whatever was returned by the handler.
    • rangeExtracter

      public GrokCaptureExtracter rangeExtracter(Consumer<Object> emit)
      Creates a GrokCaptureExtracter that will call emit with the extracted range (offset and length) when it extracts text.