Event Serializers

The file_roll sink and the hdfs sink both support theEventSerializer interface. Details of the EventSerializers that ship withFlume are provided below.

Body Text Serializer

Alias: text. This interceptor writes the body of the event to an outputstream without any transformation or modification. The event headers areignored. Configuration options are as follows:

Property NameDefaultDescription
appendNewlinetrueWhether a newline will be appended to each event at write time. The defaultof true assumes that events do not contain newlines, for legacy reasons.

Example for agent named a1:

  1. a1.sinks = k1
  2. a1.sinks.k1.type = file_roll
  3. a1.sinks.k1.channel = c1
  4. a1.sinks.k1.sink.directory = /var/log/flume
  5. a1.sinks.k1.sink.serializer = text
  6. a1.sinks.k1.sink.serializer.appendNewline = false

“Flume Event” Avro Event Serializer

Alias: avro_event.

This interceptor serializes Flume events into an Avro container file. The schema used is the same schema used forFlume events in the Avro RPC mechanism.

This serializer inherits from the AbstractAvroEventSerializer class.

Configuration options are as follows:

Property NameDefaultDescription
syncIntervalBytes2048000Avro sync interval, in approximate bytes.
compressionCodecnullAvro compression codec. For supported codecs, see Avro’s CodecFactory docs.

Example for agent named a1:

  1. a1.sinks.k1.type = hdfs
  2. a1.sinks.k1.channel = c1
  3. a1.sinks.k1.hdfs.path = /flume/events/%y-%m-%d/%H%M/%S
  4. a1.sinks.k1.serializer = avro_event
  5. a1.sinks.k1.serializer.compressionCodec = snappy

Avro Event Serializer

Alias: This serializer does not have an alias, and must be specified using the fully-qualified class name class name.

This serializes Flume events into an Avro container file like the “Flume Event” Avro Event Serializer, however therecord schema is configurable. The record schema may be specified either as a Flume configuration property or passed in an event header.

To pass the record schema as part of the Flume configuration, use the property schemaURL as listed below.

To pass the record schema in an event header, specify either the event header flume.avro.schema.literalcontaining a JSON-format representation of the schema or flume.avro.schema.url with a URL wherethe schema may be found (hdfs:/… URIs are supported).

This serializer inherits from the AbstractAvroEventSerializer class.

Configuration options are as follows:

Property NameDefaultDescription
syncIntervalBytes2048000Avro sync interval, in approximate bytes.
compressionCodecnullAvro compression codec. For supported codecs, see Avro’s CodecFactory docs.
schemaURLnullAvro schema URL. Schemas specified in the header ovverride this option.

Example for agent named a1:

  1. a1.sinks.k1.type = hdfs
  2. a1.sinks.k1.channel = c1
  3. a1.sinks.k1.hdfs.path = /flume/events/%y-%m-%d/%H%M/%S
  4. a1.sinks.k1.serializer = org.apache.flume.sink.hdfs.AvroEventSerializer$Builder
  5. a1.sinks.k1.serializer.compressionCodec = snappy
  6. a1.sinks.k1.serializer.schemaURL = hdfs://namenode/path/to/schema.avsc