@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 |
(package private) static String |
DEFAULT_PATTERN_NAME |
(package private) static PropertyDescriptor |
GROK_EXPRESSION |
(package private) static PropertyDescriptor |
GROK_PATTERNS |
private List<io.krakens.grok.api.Grok> |
groks |
(package private) static PropertyDescriptor |
NO_MATCH_BEHAVIOR |
private NoMatchStrategy |
noMatchStrategy |
(package private) static AllowableValue |
RAW_LINE |
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() |
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, isStateful
getIdentifier, getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validate
private volatile List<io.krakens.grok.api.Grok> groks
private volatile NoMatchStrategy noMatchStrategy
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 RAW_LINE
static final AllowableValue STRING_FIELDS_FROM_GROK_EXPRESSION
static final PropertyDescriptor GROK_PATTERNS
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
private List<String> readGrokExpressions(PropertyContext propertyContext) throws IOException
IOException
static RecordSchema createRecordSchema(List<io.krakens.grok.api.Grok> groks)
private static void populateSchemaFieldNames(io.krakens.grok.api.Grok grok, String grokExpression, Collection<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
private Reader getDefaultPatterns() throws IOException
IOException
Copyright © 2023 Apache NiFi Project. All rights reserved.