@Tags(value={"grok","logs","logfiles","parse","unstructured","text","record","reader","regex","pattern","logstash"}) @CapabilityDescription(value="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.") public class GrokReader extends SchemaRegistryService implements RecordReaderFactory
Modifier and Type | Field and Description |
---|---|
(package private) static AllowableValue |
APPEND_TO_PREVIOUS_MESSAGE |
private boolean |
appendUnmatchedLine |
(package private) static String |
DEFAULT_PATTERN_NAME |
private io.krakens.grok.api.Grok |
grok |
(package private) static PropertyDescriptor |
GROK_EXPRESSION |
private io.krakens.grok.api.GrokCompiler |
grokCompiler |
(package private) static PropertyDescriptor |
NO_MATCH_BEHAVIOR |
(package private) static PropertyDescriptor |
PATTERN_FILE |
private RecordSchema |
recordSchema |
private RecordSchema |
recordSchemaFromGrok |
(package private) static AllowableValue |
SKIP_LINE |
(package private) static AllowableValue |
STRING_FIELDS_FROM_GROK_EXPRESSION |
schemaAccessStrategy
Constructor and Description |
---|
GrokReader() |
Modifier and Type | Method and Description |
---|---|
private SchemaAccessStrategy |
createAccessStrategy() |
RecordReader |
createRecordReader(Map<String,String> variables,
InputStream in,
long inputLength,
ComponentLog logger) |
(package private) static RecordSchema |
createRecordSchema(io.krakens.grok.api.Grok grok) |
protected Collection<ValidationResult> |
customValidate(ValidationContext validationContext) |
protected AllowableValue |
getDefaultSchemaAccessStrategy() |
protected SchemaAccessStrategy |
getSchemaAccessStrategy(String strategy,
SchemaRegistry schemaRegistry,
PropertyContext context) |
protected List<AllowableValue> |
getSchemaAccessStrategyValues() |
protected List<PropertyDescriptor> |
getSupportedPropertyDescriptors() |
private static void |
populateSchemaFieldNames(io.krakens.grok.api.Grok grok,
String grokExpression,
List<RecordField> fields) |
void |
preCompile(ConfigurationContext context) |
buildStrategyProperty, getConfigurationContext, getSchema, getSchema, getSchemaAccessStrategy, getSchemaAcessStrategyDescriptor, getSuppliedSchemaFields, storeSchemaAccessStrategy
abstractClearConfigContext, abstractStoreConfigContext, disabled, enabled, getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, getProperty, getStateManager, init, initialize, isEnabled
equals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, hashCode, onPropertyModified, toString, validate
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
createRecordReader
initialize
getIdentifier, getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validate
private volatile io.krakens.grok.api.GrokCompiler grokCompiler
private volatile io.krakens.grok.api.Grok grok
private volatile boolean appendUnmatchedLine
private volatile RecordSchema recordSchema
private volatile RecordSchema recordSchemaFromGrok
static final String DEFAULT_PATTERN_NAME
static final AllowableValue APPEND_TO_PREVIOUS_MESSAGE
static final AllowableValue SKIP_LINE
static final AllowableValue STRING_FIELDS_FROM_GROK_EXPRESSION
static final PropertyDescriptor PATTERN_FILE
static final PropertyDescriptor GROK_EXPRESSION
static final PropertyDescriptor NO_MATCH_BEHAVIOR
protected List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors
in class SchemaRegistryService
@OnEnabled public void preCompile(ConfigurationContext context) throws io.krakens.grok.api.exception.GrokException, IOException
io.krakens.grok.api.exception.GrokException
IOException
protected Collection<ValidationResult> customValidate(ValidationContext validationContext)
customValidate
in class SchemaRegistryService
static RecordSchema createRecordSchema(io.krakens.grok.api.Grok grok)
private static void populateSchemaFieldNames(io.krakens.grok.api.Grok grok, String grokExpression, List<RecordField> fields)
protected List<AllowableValue> getSchemaAccessStrategyValues()
getSchemaAccessStrategyValues
in class SchemaRegistryService
protected AllowableValue getDefaultSchemaAccessStrategy()
getDefaultSchemaAccessStrategy
in class SchemaRegistryService
protected SchemaAccessStrategy getSchemaAccessStrategy(String strategy, SchemaRegistry schemaRegistry, PropertyContext context)
getSchemaAccessStrategy
in class SchemaRegistryService
private SchemaAccessStrategy createAccessStrategy()
public RecordReader createRecordReader(Map<String,String> variables, InputStream in, long inputLength, ComponentLog logger) throws IOException, SchemaNotFoundException
createRecordReader
in interface RecordReaderFactory
IOException
SchemaNotFoundException
Copyright © 2020 Apache NiFi Project. All rights reserved.