Package org.apache.nifi.grok
Class GrokReader
- All Implemented Interfaces:
ConfigurableComponent
,ControllerService
,RecordReaderFactory
@Tags({"grok","logs","logfiles","parse","unstructured","text","record","reader","regex","pattern","logstash"})
@CapabilityDescription("Provides a mechanism for reading unstructured text data, such as log files, and structuring the data so that it can be processed. The service is configured using Grok patterns. The service reads from a stream of data and splits each message that it finds into a separate Record, each containing the fields that are configured. If a line in the input does not match the expected message pattern, the line of text is either considered to be part of the previous message or is skipped, depending on the configuration, with the exception of stack traces. A stack trace that is found at the end of a log message is considered to be part of the previous message but is added to the \'stackTrace\' field of the Record. If a record has no stack trace, it will have a NULL value for the stackTrace field (assuming that the schema does in fact include a stackTrace field of type String). Assuming that the schema includes a \'_raw\' field of type String, the raw message will be included in the Record.")
@Restricted(restrictions=@Restriction(requiredPermission=REFERENCE_REMOTE_RESOURCES,explanation="Patterns and Expressions can reference resources over HTTP"))
public class GrokReader
extends SchemaRegistryService
implements RecordReaderFactory
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final AllowableValue
(package private) static final String
(package private) static final PropertyDescriptor
(package private) static final PropertyDescriptor
private List
<io.krakens.grok.api.Grok> (package private) static final PropertyDescriptor
private NoMatchStrategy
(package private) static final AllowableValue
private RecordSchema
private RecordSchema
(package private) static final AllowableValue
(package private) static final AllowableValue
Fields inherited from class org.apache.nifi.serialization.SchemaRegistryService
schemaAccessStrategy
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate SchemaAccessStrategy
createRecordReader
(Map<String, String> variables, InputStream in, long inputLength, ComponentLog logger) (package private) static RecordSchema
createRecordSchema
(List<io.krakens.grok.api.Grok> groks) protected Collection
<ValidationResult> customValidate
(ValidationContext validationContext) private Reader
protected AllowableValue
protected SchemaAccessStrategy
getSchemaAccessStrategy
(String strategy, SchemaRegistry schemaRegistry, PropertyContext context) protected List
<AllowableValue> protected List
<PropertyDescriptor> private static void
populateSchemaFieldNames
(io.krakens.grok.api.Grok grok, String grokExpression, Collection<RecordField> fields) void
preCompile
(ConfigurationContext context) readGrokExpressions
(PropertyContext propertyContext) Methods inherited from class org.apache.nifi.serialization.SchemaRegistryService
buildStrategyProperty, getConfigurationContext, getSchema, getSchema, getSchemaAccessStrategy, getSchemaAccessStrategyDescriptor, getSuppliedSchemaFields, migrateProperties, storeSchemaAccessStrategy
Methods inherited from class org.apache.nifi.controller.AbstractControllerService
abstractClearConfigContext, abstractStoreConfigContext, disabled, enabled, getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, getProperty, getStateManager, init, initialize, isEnabled
Methods inherited from class org.apache.nifi.components.AbstractConfigurableComponent
equals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, hashCode, onPropertyModified, toString, validate
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.nifi.components.ConfigurableComponent
getIdentifier, getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validate
Methods inherited from interface org.apache.nifi.controller.ControllerService
initialize, isStateful, migrateProperties
Methods inherited from interface org.apache.nifi.serialization.RecordReaderFactory
createRecordReader
-
Field Details
-
groks
-
noMatchStrategy
-
recordSchema
-
recordSchemaFromGrok
-
DEFAULT_PATTERN_NAME
- See Also:
-
APPEND_TO_PREVIOUS_MESSAGE
-
SKIP_LINE
-
RAW_LINE
-
STRING_FIELDS_FROM_GROK_EXPRESSION
-
GROK_PATTERNS
-
GROK_EXPRESSION
-
NO_MATCH_BEHAVIOR
-
-
Constructor Details
-
GrokReader
public GrokReader()
-
-
Method Details
-
getSupportedPropertyDescriptors
- Overrides:
getSupportedPropertyDescriptors
in classSchemaRegistryService
-
preCompile
@OnEnabled public void preCompile(ConfigurationContext context) throws io.krakens.grok.api.exception.GrokException, IOException - Throws:
io.krakens.grok.api.exception.GrokException
IOException
-
customValidate
- Overrides:
customValidate
in classSchemaRegistryService
-
readGrokExpressions
- Throws:
IOException
-
createRecordSchema
-
populateSchemaFieldNames
private static void populateSchemaFieldNames(io.krakens.grok.api.Grok grok, String grokExpression, Collection<RecordField> fields) -
getSchemaAccessStrategyValues
- Overrides:
getSchemaAccessStrategyValues
in classSchemaRegistryService
-
getDefaultSchemaAccessStrategy
- Overrides:
getDefaultSchemaAccessStrategy
in classSchemaRegistryService
-
getSchemaAccessStrategy
protected SchemaAccessStrategy getSchemaAccessStrategy(String strategy, SchemaRegistry schemaRegistry, PropertyContext context) - Overrides:
getSchemaAccessStrategy
in classSchemaRegistryService
-
createAccessStrategy
-
createRecordReader
public RecordReader createRecordReader(Map<String, String> variables, InputStream in, long inputLength, ComponentLog logger) throws IOException, SchemaNotFoundException- Specified by:
createRecordReader
in interfaceRecordReaderFactory
- Throws:
IOException
SchemaNotFoundException
-
getDefaultPatterns
- Throws:
IOException
-