Flume RPC User Guide

Avro Source

Listens on Avro port and receives events from external Avro client streams. When paired with the built-in Avro Sink on another (previous hop) Flume agent, it can create tiered collection topologies. Required properties are in bold.

Property Name Default Description

channels

 — 

type

 — 

The component type name, needs to be avro

bind

 — 

hostname or IP address to listen on

port

 — 

Port # to bind to

threads

 — 

Maximum number of worker threads to spawn

selector.type

selector.*

interceptors

 — 

Space-separated list of interceptors

interceptors.*

compression-type

none

This can be "none" or "deflate". The compression-type must match the compression-type of matching AvroSource

ssl

false

Set this to true to enable SSL encryption. If SSL is enabled, you must also specify a "keystore" and a "keystore-password", either through component level parameters (see below) or as global SSL parameters (see SSL/TLS support section).

keystore

 — 

This is the path to a Java keystore file. If not specified here, then the global keystore will be used (if defined, otherwise configuration error).

keystore-password

 — 

The password for the Java keystore. If not specified here, then the global keystore password will be used (if defined, otherwise configuration error).

keystore-type

JKS

The type of the Java keystore. This can be "JKS" or "PKCS12". If not specified here, then the global keystore type will be used (if defined, otherwise the default is JKS).

exclude-protocols

SSLv3

Space-separated list of SSL/TLS protocols to exclude. SSLv3 will always be excluded in addition to the protocols specified.

include-protocols

 — 

Space-separated list of SSL/TLS protocols to include. The enabled protocols will be the included protocols without the excluded protocols. If included-protocols is empty, it includes every supported protocols.

exclude-cipher-suites

 — 

Space-separated list of cipher suites to exclude.

include-cipher-suites

 — 

Space-separated list of cipher suites to include. The enabled cipher suites will be the included cipher suites without the excluded cipher suites. If included-cipher-suites is empty, it includes every supported cipher suites.

ipFilter

false

Set this to true to enable ipFiltering for netty

ipFilterRules

 — 

Define N netty ipFilter pattern rules with this config.

Example for agent named a1:

  • Properties

  • YAML

  • JSON

a1.sources = r1
a1.channels = c1
a1.sources.r1.type = avro
a1.sources.r1.channels = c1
a1.sources.r1.bind = 0.0.0.0
a1.sources.r1.port = 4141
a1:
  sources:
    r1:
      type: avro
      channels: c1
      bind: '0.0.0.0'
      port: 4141
  channels: c1
"a1": {
  "sources": {
    "r1": {
      "type": "avro",
      "channels": "c1",
      "bind": "0.0.0.0",
      "port": 4141
    }
  },
  "channels": "c1"
}

Example of ipFilterRules

ipFilterRules defines N netty ipFilters separated by a comma a pattern rule must be in this format.

<'allow' or deny>:<'ip' or 'name' for computer name>:<pattern> or allow/deny:ip/name:pattern

example: ipFilterRules=allow:ip:127.*,allow:name:localhost,deny:ip:*

Note that the first rule to match will apply as the example below shows from a client on the localhost

This will Allow the client on localhost be deny clients from any other ip "allow:name:localhost,deny:ip:*" This will deny the client on localhost be allow clients from any other ip "deny:name:localhost,allow:ip:*"

Thrift Source

Listens on Thrift port and receives events from external Thrift client streams. When paired with the built-in ThriftSink on another (previous hop) Flume agent, it can create tiered collection topologies. Thrift source can be configured to start in secure mode by enabling kerberos authentication. agent-principal and agent-keytab are the properties used by the Thrift source to authenticate to the kerberos KDC. Required properties are in bold.

Property Name Default Description

channels

 — 

type

 — 

The component type name, needs to be thrift

bind

 — 

hostname or IP address to listen on

port

 — 

Port # to bind to

threads

 — 

Maximum number of worker threads to spawn

selector.type

selector.*

interceptors

 — 

Space separated list of interceptors

interceptors.*

ssl

false

Set this to true to enable SSL encryption. If SSL is enabled, you must also specify a "keystore" and a "keystore-password", either through component level parameters (see below) or as global SSL parameters (see SSL/TLS support section)

keystore

 — 

This is the path to a Java keystore file. If not specified here, then the global keystore will be used (if defined, otherwise configuration error).

keystore-password

 — 

The password for the Java keystore. If not specified here, then the global keystore password will be used (if defined, otherwise configuration error).

keystore-type

JKS

The type of the Java keystore. This can be "JKS" or "PKCS12". If not specified here, then the global keystore type will be used (if defined, otherwise the default is JKS).

exclude-protocols

SSLv3

Space-separated list of SSL/TLS protocols to exclude. SSLv3 will always be excluded in addition to the protocols specified.

include-protocols

 — 

Space-separated list of SSL/TLS protocols to include. The enabled protocols will be the included protocols without the excluded protocols. If included-protocols is empty, it includes every supported protocols.

exclude-cipher-suites

 — 

Space-separated list of cipher suites to exclude.

include-cipher-suites

 — 

Space-separated list of cipher suites to include. The enabled cipher suites will be the included cipher suites without the excluded cipher suites.

kerberos

false

Set to true to enable kerberos authentication. In kerberos mode, agent-principal and agent-keytab are required for successful authentication. The Thrift source in secure mode, will accept connections only from Thrift clients that have kerberos enabled and are successfully authenticated to the kerberos KDC.

agent-principal

 — 

The kerberos principal used by the Thrift Source to authenticate to the kerberos KDC.

agent-keytab

—-

The keytab location used by the Thrift Source in combination with the agent-principal to authenticate to the kerberos KDC.

Example for agent named a1:

  • Properties

  • YAML

  • JSON

a1.sources = r1
a1.channels = c1
a1.sources.r1.type = thrift
a1.sources.r1.channels = c1
a1.sources.r1.bind = 0.0.0.0
a1.sources.r1.port = 4141
a1:
  sources:
    r1:
      type: thrift
      channels: c1
      bind: '0.0.0.0'
      port: 4141
  channels: c1
"a1": {
  "sources": {
    "r1": {
      "type": "thrift",
      "channels": "c1",
      "bind": "0.0.0.0",
      "port": 4141
    }
  },
  "channels": "c1"
}

Spooling Directory Source

This source lets you ingest data by placing files to be ingested into a "spooling" directory on disk. This source will watch the specified directory for new files, and will parse events out of new files as they appear. The event parsing logic is pluggable. After a given file has been fully read into the channel, completion by default is indicated by renaming the file or it can be deleted or the trackerDir is used to keep track of processed files.

Unlike the Exec source, this source is reliable and will not miss data, even if Flume is restarted or killed. In exchange for this reliability, only immutable, uniquely-named files must be dropped into the spooling directory. Flume tries to detect these problem conditions and will fail loudly if they are violated:

  1. If a file is written to after being placed into the spooling directory, Flume will print an error to its log file and stop processing.

  2. If a file name is reused at a later time, Flume will print an error to its log file and stop processing.

To avoid the above issues, it may be useful to add a unique identifier (such as a timestamp) to log file names when they are moved into the spooling directory.

Despite the reliability guarantees of this source, there are still cases in which events may be duplicated if certain downstream failures occur. This is consistent with the guarantees offered by other Flume components.

Property Name Default Description

channels

 — 

type

 — 

The component type name, needs to be spooldir.

spoolDir

 — 

The directory from which to read files from.

fileSuffix

.COMPLETED

Suffix to append to completely ingested files

deletePolicy

never

When to delete completed files: never or immediate

fileHeader

false

Whether to add a header storing the absolute path filename.

fileHeaderKey

file

Header key to use when appending absolute path filename to event header.

basenameHeader

false

Whether to add a header storing the basename of the file.

basenameHeaderKey

basename

Header Key to use when appending basename of file to event header.

includePattern

^.*$

Regular expression specifying which files to include. It can used together with ignorePattern. If a file matches both ignorePattern and includePattern regex, the file is ignored.

ignorePattern

^$

Regular expression specifying which files to ignore (skip). It can used together with includePattern. If a file matches both ignorePattern and includePattern regex, the file is ignored.

trackerDir

.flumespool

Directory to store metadata related to processing of files. If this path is not an absolute path, then it is interpreted as relative to the spoolDir.

trackingPolicy

rename

The tracking policy defines how file processing is tracked. It can be "rename" or "tracker_dir". This parameter is only effective if the deletePolicy is "never". "rename" - After processing files they get renamed according to the fileSuffix parameter. "tracker_dir" - Files are not renamed but a new empty file is created in the trackerDir. The new tracker file name is derived from the ingested one plus the fileSuffix.

consumeOrder

oldest

In which order files in the spooling directory will be consumed oldest, youngest and random. In case of oldest and youngest, the last modified time of the files will be used to compare the files. In case of a tie, the file with smallest lexicographical order will be consumed first. In case of random any file will be picked randomly. When using oldest and youngest the whole directory will be scanned to pick the oldest/youngest file, which might be slow if there are a large number of files, while using random may cause old files to be consumed very late if new files keep coming in the spooling directory.

pollDelay

500

Delay (in milliseconds) used when polling for new files.

recursiveDirectorySearch

false

Whether to monitor sub directories for new files to read.

maxBackoff

4000

The maximum time (in millis) to wait between consecutive attempts to write to the channel(s) if the channel is full. The source will start at a low backoff and increase it exponentially each time the channel throws a ChannelException, up to the value specified by this parameter.

batchSize

100

Granularity at which to batch transfer to the channel

inputCharset

UTF-8

Character set used by deserializers that treat the input file as text.

decodeErrorPolicy

FAIL

What to do when we see a non-decodable character in the input file. FAIL: Throw an exception and fail to parse the file. REPLACE: Replace the unparseable character with the "replacement character" char, typically Unicode U+FFFD. IGNORE: Drop the unparseable character sequence.

deserializer

LINE

Specify the deserializer used to parse the file into events. Defaults to parsing each line as an event. The class specified must implement EventDeserializer.Builder.

deserializer.*

Varies per event deserializer.

bufferMaxLines

 — 

(Obsolete) This option is now ignored.

bufferMaxLineLength

5000

(Deprecated) Maximum length of a line in the commit buffer. Use deserializer.maxLineLength instead.

selector.type

replicating

replicating or multiplexing

selector.*

Depends on the selector.type value

interceptors

 — 

Space-separated list of interceptors

interceptors.*

Example for an agent named agent-1:

  • Properties

  • YAML

  • JSON

a1.channels = ch-1
a1.sources = src-1

a1.sources.src-1.type = spooldir
a1.sources.src-1.channels = ch-1
a1.sources.src-1.spoolDir = /var/log/apache/flumeSpool
a1.sources.src-1.fileHeader = true
a1:
  channels: ch-1
  sources:
    src-1:
      type: spooldir
      channels: ch-1
      spoolDir: /var/log/apache/flumeSpool
      fileHeader: true
"a1": {
  "channels": "ch-1",
  "sources": {
    "src-1": {
      "type": "spooldir",
      "channels": "ch-1",
      "spoolDir": "/var/log/apache/flumeSpool",
      "fileHeader": true
    }
  }
}

Event Deserializers

The following event deserializers ship with Flume.

LINE

This deserializer generates one event per line of text input.

Property Name Default Description

deserializer.maxLineLength

2048

Maximum number of characters to include in a single event. If a line exceeds this length, it is truncated, and the remaining characters on the line will appear in a subsequent event.

deserializer.outputCharset

UTF-8

Charset to use for encoding events put into the channel.

AVRO

This deserializer is able to read an Avro container file, and it generates one event per Avro record in the file. Each event is annotated with a header that indicates the schema used. The body of the event is the binary Avro record data, not including the schema or the rest of the container file elements.

Note that if the spool directory source must retry putting one of these events onto a channel (for example, because the channel is full), then it will reset and retry from the most recent Avro container file sync point. To reduce potential event duplication in such a failure scenario, write sync markers more frequently in your Avro input files.

Property Name Default Description

deserializer.schemaType

HASH

How the schema is represented. By default, or when the value HASH is specified, the Avro schema is hashed and the hash is stored in every event in the event header "flume.avro.schema.hash". If LITERAL is specified, the JSON-encoded schema itself is stored in every event in the event header "flume.avro.schema.literal". Using LITERAL mode is relatively inefficient compared to HASH mode.

BlobDeserializer

This deserializer reads a Binary Large Object (BLOB) per event, typically one BLOB per file. For example a PDF or JPG file. Note that this approach is not suitable for very large objects because the entire BLOB is buffered in RAM.

Property Name Default Description

deserializer

 — 

The FQCN of this class: org.apache.flume.sink.solr.morphline.BlobDeserializer$Builder

deserializer.maxBlobLength

100000000

The maximum number of bytes to read and buffer for a given request

Avro Sink

This sink forms one half of Flume’s tiered collection support. Flume events sent to this sink are turned into Avro events and sent to the configured hostname / port pair. The events are taken from the configured Channel in batches of the configured batch size. Required properties are in bold.

Property Name Default Description

channel

 — 

type

 — 

The component type name, needs to be avro.

hostname

 — 

The hostname or IP address to bind to.

port

 — 

The port # to listen on.

batch-size

100

number of event to batch together for send.

connect-timeout

20000

Amount of time (ms) to allow for the first (handshake) request.

request-timeout

20000

Amount of time (ms) to allow for requests after the first.

reset-connection-interval

none

Amount of time (s) before the connection to the next hop is reset. This will force the Avro Sink to reconnect to the next hop. This will allow the sink to connect to hosts behind a hardware load-balancer when news hosts are added without having to restart the agent.

compression-type

none

This can be "none" or "deflate". The compression-type must match the compression-type of matching AvroSource

compression-level

6

The level of compression to compress event. 0 = no compression and 1-9 is compression. The higher the number the more compression

ssl

false

Set to true to enable SSL for this AvroSink. When configuring SSL, you can optionally set a "truststore", "truststore-password", "truststore-type", and specify whether to "trust-all-certs".

trust-all-certs

false

If this is set to true, SSL server certificates for remote servers (Avro Sources) will not be checked. This should NOT be used in production because it makes it easier for an attacker to execute a man-in-the-middle attack and "listen in" on the encrypted connection.

truststore

 — 

The path to a custom Java truststore file. Flume uses the certificate authority information in this file to determine whether the remote Avro Source’s SSL authentication credentials should be trusted. If not specified, then the global keystore will be used. If the global keystore not specified either, then the default Java JSSE certificate authority files (typically "jssecacerts" or "cacerts" in the Oracle JRE) will be used.

truststore-password

 — 

The password for the truststore. If not specified, then the global keystore password will be used (if defined).

truststore-type

JKS

The type of the Java truststore. This can be "JKS" or other supported Java truststore type. If not specified, then the global keystore type will be used (if defined, otherwise the defautl is JKS).

exclude-protocols

SSLv3

Space-separated list of SSL/TLS protocols to exclude. SSLv3 will always be excluded in addition to the protocols specified.

maxIoWorkers

2 * the number of available processors in the machine

The maximum number of I/O worker threads. This is configured on the NettyAvroRpcClient NioClientSocketChannelFactory.

Example for agent named a1:

  • Properties

  • YAML

  • JSON

a1.channels = c1
a1.sinks = k1
a1.sinks.k1.type = avro
a1.sinks.k1.channel = c1
a1.sinks.k1.hostname = 10.10.10.10
a1.sinks.k1.port = 4545
a1:
  channels: c1
  sinks:
    k1:
      type: avro
      channel: c1
      hostname: '10.10.10.10'
      port: 4545
"a1": {
  "channels": "c1",
  "sinks": {
    "k1": {
      "type": "avro",
      "channel": "c1",
      "hostname": "10.10.10.10",
      "port": 4545
    }
  }
}

Thrift Sink

This sink forms one half of Flume’s tiered collection support. Flume events sent to this sink are turned into Thrift events and sent to the configured hostname / port pair. The events are taken from the configured Channel in batches of the configured batch size.

Thrift sink can be configured to start in secure mode by enabling kerberos authentication. To communicate with a Thrift source started in secure mode, the Thrift sink should also operate in secure mode. client-principal and client-keytab are the properties used by the Thrift sink to authenticate to the kerberos KDC. The server-principal represents the principal of the Thrift source this sink is configured to connect to in secure mode. Required properties are in bold.

Property Name Default Description

channel

 — 

type

 — 

The component type name, needs to be thrift.

hostname

 — 

The hostname or IP address to bind to.

port

 — 

The port # to listen on.

batch-size

100

number of event to batch together for send.

connect-timeout

20000

Amount of time (ms) to allow for the first (handshake) request.

request-timeout

20000

Amount of time (ms) to allow for requests after the first.

connection-reset-interval

none

Amount of time (s) before the connection to the next hop is reset. This will force the Thrift Sink to reconnect to the next hop. This will allow the sink to connect to hosts behind a hardware load-balancer when news hosts are added without having to restart the agent.

ssl

false

Set to true to enable SSL for this ThriftSink. When configuring SSL, you can optionally set a "truststore", "truststore-password" and "truststore-type"

truststore

 — 

The path to a custom Java truststore file. Flume uses the certificate authority information in this file to determine whether the remote Thrift Source’s SSL authentication credentials should be trusted. If not specified, then the global keystore will be used. If the global keystore not specified either, then the default Java JSSE certificate authority files (typically "jssecacerts" or "cacerts" in the Oracle JRE) will be used.

truststore-password

 — 

The password for the truststore. If not specified, then the global keystore password will be used (if defined).

truststore-type

JKS

The type of the Java truststore. This can be "JKS" or other supported Java truststore type. If not specified, then the global keystore type will be used (if defined, otherwise the defautl is JKS).

exclude-protocols

SSLv3

Space-separated list of SSL/TLS protocols to exclude

kerberos

false

Set to true to enable kerberos authentication. In kerberos mode, client-principal, client-keytab and server-principal are required for successful authentication and communication to a kerberos enabled Thrift Source.

client-principal

—-

The kerberos principal used by the Thrift Sink to authenticate to the kerberos KDC.

client-keytab

—-

The keytab location used by the Thrift Sink in combination with the client-principal to authenticate to the kerberos KDC.

server-principal

 — 

The kerberos principal of the Thrift Source to which the Thrift Sink is configured to connect to.

Example for agent named a1:

  • Properties

  • YAML

  • JSON

a1.channels = c1
a1.sinks = k1
a1.sinks.k1.type = thrift
a1.sinks.k1.channel = c1
a1.sinks.k1.hostname = 10.10.10.10
a1.sinks.k1.port = 4545
a1:
  channels: c1
  sinks:
    k1:
      type: thrift
      channel: c1
      hostname: '10.10.10.10'
      port: 4545
"a1": {
  "channels": "c1",
  "sinks": {
    "k1": {
      "type": "thrift",
      "channel": "c1",
      "hostname": "10.10.10.10",
      "port": 4545
    }
  }
}

"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 for Flume events in the Avro RPC mechanism.

This serializer inherits from the AbstractAvroEventSerializer class.

Configuration options are as follows:

Property Name Default Description

syncIntervalBytes

2048000

Avro sync interval, in approximate bytes.

compressionCodec

null

Avro compression codec. For supported codecs, see Avro’s CodecFactory docs.

Example for agent named a1:

  • Properties

  • YAML

  • JSON

a1.sinks.k1.type = hdfs
a1.sinks.k1.channel = c1
a1.sinks.k1.hdfs.path = /flume/events/%Y-%m-%d/%H%M/%S
a1.sinks.k1.serializer = avro_event
a1.sinks.k1.serializer.compressionCodec = snappy
a1:
  sinks:
    k1:
      type: hdfs
      channel: c1
      hdfs:
        path: /flume/events/%Y-%m-%d/%H%M/%S
      serializer: avro_event
      serializer.compressionCodec: snappy
"a1": {
  "sinks": {
    "k1": {
      "type": "hdfs",
      "channel": "c1",
      "hdfs": {
        "path": "/flume/events/%Y-%m-%d/%H%M/%S"
      },
      "serializer": "avro_event",
      "serializer.compressionCodec": "snappy"
    }
  }
}

Avro compatibility

Flume 2.x uses the same Avro RPC protocol as Flume 1.x, but the protocol types moved from the org.apache.flume.source.avro namespace to org.apache.flume.avro.

  • Flume 2.x clients (including the Avro Sink) can send events to Flume 1.x Avro Sources.

  • Flume 1.x clients (including the Avro Sink and the Log4j Appender) can send events to Flume 2.x Avro Sources only if they use Avro 1.11.1 or later. Flume 1.11.0 ships with Avro 1.11.0, which compares enum names including their namespace (see AVRO-3133) and rejects the renamed Status enum in the server’s response with:

    org.apache.avro.AvroTypeException: Found org.apache.flume.avro.Status, expecting org.apache.flume.source.avro.Status

    The Flume 2.x source has already accepted the event, so a client that retries after this error (such as the Avro Sink) delivers it twice. To fix this, replace avro-1.11.0.jar on the client’s classpath with Avro 1.11.1 or a later 1.11.x release.

An SSD failure that is configured with a RAID level of 0 cannot guarantee delivery. When using a file channel always use a more reliable RAID level.