Flume Kafka User Guide

Kafka Source

Kafka Source is an Apache Kafka consumer that reads messages from Kafka topics. If you have multiple Kafka sources running, you can configure them with the same Consumer Group so each will read a unique set of partitions for the topics. This currently supports Kafka server releases 0.10.1.0 or higher. Testing was done up to 2.0.1 that was the highest avilable version at the time of the release.

Property Name Default Description

channels

 — 

type

 — 

The component type name, needs to be org.apache.flume.source.kafka.KafkaSource

kafka.bootstrap.servers

 — 

List of brokers in the Kafka cluster used by the source

kafka.consumer.group.id

flume

Unique identified of consumer group. Setting the same id in multiple sources or agents indicates that they are part of the same consumer group

kafka.topics

 — 

Comma-separated list of topics the Kafka consumer will read messages from.

kafka.topics.regex

 — 

Regex that defines set of topics the source is subscribed on. This property has higher priority than kafka.topics and overrides kafka.topics if exists.

batchSize

1000

Maximum number of messages written to Channel in one batch

batchDurationMillis

1000

Maximum time (in ms) before a batch will be written to Channel The batch will be written whenever the first of size and time will be reached.

backoffSleepIncrement

1000

Initial and incremental wait time that is triggered when a Kafka Topic appears to be empty. Wait period will reduce aggressive pinging of an empty Kafka Topic. One second is ideal for ingestion use cases but a lower value may be required for low latency operations with interceptors.

maxBackoffSleep

5000

Maximum wait time that is triggered when a Kafka Topic appears to be empty. Five seconds is ideal for ingestion use cases but a lower value may be required for low latency operations with interceptors.

useFlumeEventFormat

false

By default events are taken as bytes from the Kafka topic directly into the event body. Set to true to read events as the Flume Avro binary format. Used in conjunction with the same property on the KafkaSink or with the parseAsFlumeEvent property on the Kafka Channel this will preserve any Flume headers sent on the producing side.

setTopicHeader

true

When set to true, stores the topic of the retrieved message into a header, defined by the topicHeader property.

topicHeader

topic

Defines the name of the header in which to store the name of the topic the message was received from, if the setTopicHeader property is set to true. Care should be taken if combining with the Kafka Sink topicHeader property so as to avoid sending the message back to the same topic in a loop.

timestampHeader

 — 

If present the Kafka message timestamp value will be copied into the specified Flume header name.

header.NAME

 — 

Used to identify which headers from the Kafka message should be added as a FLume header. The value of NAME should match the Flume header name and the value should be the name of the header to be used as the Kafka header name.

kafka.consumer.security.protocol

PLAINTEXT

Set to SASL_PLAINTEXT, SASL_SSL or SSL if writing to Kafka using some level of security. See below for additional info on secure setup.

more consumer security props

If using SASL_PLAINTEXT, SASL_SSL or SSL refer to Kafka security for additional properties that need to be set on consumer.

Other Kafka Consumer Properties

 — 

These properties are used to configure the Kafka Consumer. Any consumer property supported by Kafka can be used. The only requirement is to prepend the property name with the prefix kafka.consumer. For example: kafka.consumer.auto.offset.reset

The Kafka Source overrides two Kafka consumer parameters: auto.commit.enable is set to "false" by the source and every batch is committed. Kafka source guarantees at least once strategy of messages retrieval. The duplicates can be present when the source starts. The Kafka Source also provides defaults for the key.deserializer(org.apache.kafka.common.serialization.StringSerializer) and value.deserializer(org.apache.kafka.common.serialization.ByteArraySerializer). Modification of these parameters is not recommended.

Deprecated Properties

Property Name Default Description

topic

 — 

Use kafka.topics

groupId

flume

Use kafka.consumer.group.id

zookeeperConnect

 — 

Is no longer supported by Kafka consumer client since 0.9.x. Use kafka.bootstrap.servers to establish connection with Kafka cluster

migrateZookeeperOffsets

true

When no Kafka stored offset is found, look up the offsets in Zookeeper and commit them to Kafka. This should be true to support seamless Kafka client migration from older versions of Flume. Once migrated this can be set to false, though that should generally not be required. If no Zookeeper offset is found, the Kafka configuration kafka.consumer.auto.offset.reset defines how offsets are handled. Check Kafka documentation for details

Example for topic subscription by comma-separated topic list.

  • Properties

  • YAML

  • JSON

tier1.sources.source1.type = org.apache.flume.source.kafka.KafkaSource
tier1.sources.source1.channels = channel1
tier1.sources.source1.batchSize = 5000
tier1.sources.source1.batchDurationMillis = 2000
tier1.sources.source1.kafka.bootstrap.servers = localhost:9092
tier1.sources.source1.kafka.topics = test1, test2
tier1.sources.source1.kafka.consumer.group.id = custom.g.id
tier1:
  sources:
    source1:
      type: org.apache.flume.source.kafka.KafkaSource
      channels: channel1
      batchSize: 5000
      batchDurationMillis: 2000
      kafka:
        bootstrap:
          servers: localhost:9092
        topics: test1, test2
        consumer:
          group:
            id: custom.g.id
"tier1": {
  "sources": {
    "source1": {
      "type": "org.apache.flume.source.kafka.KafkaSource",
      "channels": "channel1",
      "batchSize": 5000,
      "batchDurationMillis": 2000,
      "kafka": {
        "bootstrap": {
          "servers": "localhost:9092"
        },
        "topics": "test1, test2",
        "consumer": {
          "group": {
            "id": "custom.g.id"
          }
        }
      }
    }
  }
}

Example for topic subscription by regex

  • Properties

  • YAML

  • JSON

tier1.sources.source1.type = org.apache.flume.source.kafka.KafkaSource
tier1.sources.source1.channels = channel1
tier1.sources.source1.kafka.bootstrap.servers = localhost:9092
tier1.sources.source1.kafka.topics.regex = ^topic[0-9]$
# the default kafka.consumer.group.id=flume is used
tier1:
  sources:
    source1:
      type: org.apache.flume.source.kafka.KafkaSource
      channels: channel1
      kafka:
        bootstrap:
          servers: localhost:9092
        topics:
          regex: ^topic[0-9]$
# the default kafka.consumer.group.id=flume is used
"tier1": {
  "sources": {
    "source1": {
      "type": "org.apache.flume.source.kafka.KafkaSource",
      "channels": "channel1",
      "kafka": {
        "bootstrap": {
          "servers": "localhost:9092"
        },
        "topics": {
          "regex": "^topic[0-9]$"
        }
      }
    }
  }
}

Security and Kafka Source:

Secure authentication as well as data encryption is supported on the communication channel between Flume and Kafka. For secure authentication SASL/GSSAPI (Kerberos V5) or SSL (even though the parameter is named SSL, the actual protocol is a TLS implementation) can be used from Kafka version 0.9.0.

As of now data encryption is solely provided by SSL/TLS.

Setting kafka.consumer.security.protocol to any of the following value means:

  • SASL_PLAINTEXT - Kerberos or plaintext authentication with no data encryption

  • SASL_SSL - Kerberos or plaintext authentication with data encryption

  • SSL - TLS based encryption with optional authentication.

There is a performance degradation when SSL is enabled, the magnitude of which depends on the CPU type and the JVM implementation. Reference: Kafka security overview and the jira for tracking this issue: KAFKA-2561

TLS and Kafka Source:

Please read the steps described in Configuring Kafka Clients SSL to learn about additional configuration settings for fine tuning for example any of the following: security provider, cipher suites, enabled protocols, truststore or keystore types.

Example configuration with server side authentication and data encryption.

  • Properties

  • YAML

  • JSON

a1.sources.source1.type = org.apache.flume.source.kafka.KafkaSource
a1.sources.source1.kafka.bootstrap.servers = kafka-1:9093,kafka-2:9093,kafka-3:9093
a1.sources.source1.kafka.topics = mytopic
a1.sources.source1.kafka.consumer.group.id = flume-consumer
a1.sources.source1.kafka.consumer.security.protocol = SSL
# optional, the global truststore can be used alternatively
a1.sources.source1.kafka.consumer.ssl.truststore.location=/path/to/truststore.jks
a1.sources.source1.kafka.consumer.ssl.truststore.password=<password to access the truststore>
a1:
  sources:
    source1:
      type: org.apache.flume.source.kafka.KafkaSource
      kafka:
        bootstrap:
          servers: kafka-1:9093,kafka-2:9093,kafka-3:9093
        topics: mytopic
        consumer:
          group:
            id: flume-consumer
          security:
            protocol: SSL
          ssl:
            truststore:
              # optional, the global truststore can be used alternatively
              location: /path/to/truststore.jks
              password: <password to access the truststore>
"a1": {
  "sources": {
    "source1": {
      "type": "org.apache.flume.source.kafka.KafkaSource",
      "kafka": {
        "bootstrap": {
          "servers": "kafka-1:9093,kafka-2:9093,kafka-3:9093"
        },
        "topics": "mytopic",
        "consumer": {
          "group": {
            "id": "flume-consumer"
          },
          "security": {
            "protocol": "SSL"
          },
          "ssl": {
            "truststore": {
              "location": "/path/to/truststore.jks",
              "password": "<password to access the truststore>"
            }
          }
        }
      }
    }
  }
}

Specifying the truststore is optional here, the global truststore can be used instead. For more details about the global SSL setup, see the SSL/TLS support section.

Note: By default the property ssl.endpoint.identification.algorithm is not defined, so hostname verification is not performed. In order to enable hostname verification, set the following properties

  • Properties

  • YAML

  • JSON

a1.sources.source1.kafka.consumer.ssl.endpoint.identification.algorithm=HTTPS
a1:
  sources:
    source1:
      kafka:
        consumer:
          ssl:
            endpoint:
              identification:
                algorithm: HTTPS
"a1": {
  "sources": {
    "source1": {
      "kafka": {
        "consumer": {
          "ssl": {
            "endpoint": {
              "identification": {
                "algorithm": "HTTPS"
              }
            }
          }
        }
      }
    }
  }
}

Once enabled, clients will verify the server’s fully qualified domain name (FQDN) against one of the following two fields:

If client side authentication is also required then additionally the following needs to be added to Flume agent configuration or the global SSL setup can be used (see SSL/TLS support section). Each Flume agent has to have its client certificate which has to be trusted by Kafka brokers either individually or by their signature chain. Common example is to sign each client certificate by a single Root CA which in turn is trusted by Kafka brokers.

  • Properties

  • YAML

  • JSON

# optional, the global keystore can be used alternatively
a1.sources.source1.kafka.consumer.ssl.keystore.location=/path/to/client.keystore.jks
a1.sources.source1.kafka.consumer.ssl.keystore.password=<password to access the keystore>
# optional, the global keystore can be used alternatively
a1:
  sources:
    source1:
      kafka:
        consumer:
          ssl:
            keystore:
              location: /path/to/client.keystore.jks
              password: <password to access the keystore>
"a1": {
  "sources": {
    "source1": {
      "kafka": {
        "consumer": {
          "ssl": {
            "keystore": {
              "location": "/path/to/client.keystore.jks",
              "password": "<password to access the keystore>"
            }
          }
        }
      }
    }
  }
}

If keystore and key use different password protection then ssl.key.password property will provide the required additional secret for both consumer keystores:

  • Properties

  • YAML

  • JSON

a1.sources.source1.kafka.consumer.ssl.key.password=<password to access the key>
a1:
  sources:
    source1:
      kafka:
        consumer:
          ssl:
            key:
              password: <password to access the key>
"a1": {
  "sources": {
    "source1": {
      "kafka": {
        "consumer": {
          "ssl": {
            "key": {
              "password": "<password to access the key>"
            }
          }
        }
      }
    }
  }
}

Kerberos and Kafka Source:

To use Kafka source with a Kafka cluster secured with Kerberos, set the consumer.security.protocol properties noted above for consumer. The Kerberos keytab and principal to be used with Kafka brokers is specified in a JAAS file’s "KafkaClient" section. "Client" section describes the Zookeeper connection if needed. See Kafka doc for information on the JAAS file contents. The location of this JAAS file and optionally the system wide kerberos configuration can be specified via JAVA_OPTS in flume-env.sh:

JAVA_OPTS="$JAVA_OPTS -Djava.security.krb5.conf=/path/to/krb5.conf"
JAVA_OPTS="$JAVA_OPTS -Djava.security.auth.login.config=/path/to/flume_jaas.conf"

Example secure configuration using SASL_PLAINTEXT:

  • Properties

  • YAML

  • JSON

a1.sources.source1.type = org.apache.flume.source.kafka.KafkaSource
a1.sources.source1.kafka.bootstrap.servers = kafka-1:9093,kafka-2:9093,kafka-3:9093
a1.sources.source1.kafka.topics = mytopic
a1.sources.source1.kafka.consumer.group.id = flume-consumer
a1.sources.source1.kafka.consumer.security.protocol = SASL_PLAINTEXT
a1.sources.source1.kafka.consumer.sasl.mechanism = GSSAPI
a1.sources.source1.kafka.consumer.sasl.kerberos.service.name = kafka
a1:
  sources:
    source1:
      type: org.apache.flume.source.kafka.KafkaSource
      kafka:
        bootstrap:
          servers: kafka-1:9093,kafka-2:9093,kafka-3:9093
        topics: mytopic
        consumer:
          group:
            id: flume-consumer
          security:
            protocol: SASL_PLAINTEXT
          sasl:
            mechanism: GSSAPI
            kerberos:
              service:
                name: kafka
"a1": {
  "sources": {
    "source1": {
      "type": "org.apache.flume.source.kafka.KafkaSource",
      "kafka": {
        "bootstrap": {
          "servers": "kafka-1:9093,kafka-2:9093,kafka-3:9093"
        },
        "topics": "mytopic",
        "consumer": {
          "group": {
            "id": "flume-consumer"
          },
          "security": {
            "protocol": "SASL_PLAINTEXT"
          },
          "sasl": {
            "mechanism": "GSSAPI",
            "kerberos": {
              "service": {
                "name": "kafka"
              }
            }
          }
        }
      }
    }
  }
}

Example secure configuration using SASL_SSL:

  • Properties

  • YAML

  • JSON

a1.sources.source1.type = org.apache.flume.source.kafka.KafkaSource
a1.sources.source1.kafka.bootstrap.servers = kafka-1:9093,kafka-2:9093,kafka-3:9093
a1.sources.source1.kafka.topics = mytopic
a1.sources.source1.kafka.consumer.group.id = flume-consumer
a1.sources.source1.kafka.consumer.security.protocol = SASL_SSL
a1.sources.source1.kafka.consumer.sasl.mechanism = GSSAPI
a1.sources.source1.kafka.consumer.sasl.kerberos.service.name = kafka
# optional, the global truststore can be used alternatively
a1.sources.source1.kafka.consumer.ssl.truststore.location=/path/to/truststore.jks
a1.sources.source1.kafka.consumer.ssl.truststore.password=<password to access the truststore>
a1:
  sources:
    source1:
      type: org.apache.flume.source.kafka.KafkaSource
      kafka:
        bootstrap:
          servers: kafka-1:9093,kafka-2:9093,kafka-3:9093
        topics: mytopic
        consumer:
          group:
            id: flume-consumer
          security:
            protocol: SASL_SSL
          sasl:
            mechanism: GSSAPI
            kerberos:
              service:
                name: kafka
          ssl:
            truststore:
              # optional, the global truststore can be used alternatively
              location: /path/to/truststore.jks
              password: <password to access the truststore>
"a1": {
  "sources": {
    "source1": {
      "type": "org.apache.flume.source.kafka.KafkaSource",
      "kafka": {
        "bootstrap": {
          "servers": "kafka-1:9093,kafka-2:9093,kafka-3:9093"
        },
        "topics": "mytopic",
        "consumer": {
          "group": {
            "id": "flume-consumer"
          },
          "security": {
            "protocol": "SASL_SSL"
          },
          "sasl": {
            "mechanism": "GSSAPI",
            "kerberos": {
              "service": {
                "name": "kafka"
              }
            }
          },
          "ssl": {
            "truststore": {
              "location": "/path/to/truststore.jks",
              "password": "<password to access the truststore>"
            }
          }
        }
      }
    }
  }
}

Sample JAAS file. For reference of its content please see client config sections of the desired authentication mechanism (GSSAPI/PLAIN) in Kafka documentation of SASL configuration. Since the Kafka Source may also connect to Zookeeper for offset migration, the "Client" section was also added to this example. This won’t be needed unless you require offset migration, or you require this section for other secure components. Also please make sure that the operating system user of the Flume processes has read privileges on the jaas and keytab files.

Client {
  com.sun.security.auth.module.Krb5LoginModule required
  useKeyTab=true
  storeKey=true
  keyTab="/path/to/keytabs/flume.keytab"
  principal="flume/flumehost1.example.com@YOURKERBEROSREALM";
};

KafkaClient {
  com.sun.security.auth.module.Krb5LoginModule required
  useKeyTab=true
  storeKey=true
  keyTab="/path/to/keytabs/flume.keytab"
  principal="flume/flumehost1.example.com@YOURKERBEROSREALM";
};

Kafka Sink

This is a Flume Sink implementation that can publish data to a Kafka topic. One of the objective is to integrate Flume with Kafka so that pull based processing systems can process the data coming through various Flume sources.

This currently supports Kafka server releases 0.10.1.0 or higher. Testing was done up to 2.0.1 that was the highest avilable version at the time of the release.

Required properties are marked in bold font.

Property Name Default Description

type

 — 

Must be set to org.apache.flume.sink.kafka.KafkaSink

kafka.bootstrap.servers

 — 

List of brokers Kafka-Sink will connect to, to get the list of topic partitions This can be a partial list of brokers, but we recommend at least two for HA. The format is comma separated list of hostname:port

kafka.topic

default-flume-topic

The topic in Kafka to which the messages will be published. If this parameter is configured, messages will be published to this topic. If the event header contains a "topic" field, the event will be published to that topic overriding the topic configured here. Arbitrary header substitution is supported, eg. %{header} is replaced with value of event header named "header". (If using the substitution, it is recommended to set "auto.create.topics.enable" property of Kafka broker to true.)

flumeBatchSize

100

How many messages to process in one batch. Larger batches improve throughput while adding latency.

kafka.producer.acks

1

How many replicas must acknowledge a message before its considered successfully written. Accepted values are 0 (Never wait for acknowledgement), 1 (wait for leader only), -1 (wait for all replicas) Set this to -1 to avoid data loss in some cases of leader failure.

useFlumeEventFormat

false

By default events are put as bytes onto the Kafka topic directly from the event body. Set to true to store events as the Flume Avro binary format. Used in conjunction with the same property on the KafkaSource or with the parseAsFlumeEvent property on the Kafka Channel this will preserve any Flume headers for the producing side.

defaultPartitionId

 — 

Specifies a Kafka partition ID (integer) for all events in this channel to be sent to, unless overriden by partitionIdHeader. By default, if this property is not set, events will be distributed by the Kafka Producer’s partitioner - including by key if specified (or by a partitioner specified by kafka.partitioner.class).

partitionIdHeader

 — 

When set, the sink will take the value of the field named using the value of this property from the event header and send the message to the specified partition of the topic. If the value represents an invalid partition, an EventDeliveryException will be thrown. If the header value is present then this setting overrides defaultPartitionId.

allowTopicOverride

true

When set, the sink will allow a message to be produced into a topic specified by the topicHeader property (if provided).

topicHeader

topic

When set in conjunction with allowTopicOverride will produce a message into the value of the header named using the value of this property. Care should be taken when using in conjunction with the Kafka Source topicHeader property to avoid creating a loopback.

timestampHeader

 — 

The header containing the caller provided timestamp value to use. If not provided the current time will be used.

header.NAME

 — 

Used to identify which headers from the Flume Event should be passed to Kafka. The value of NAME should match the Flume header name and the value should be the name of the header to be used as the Kafka header name.

kafka.producer.security.protocol

PLAINTEXT

Set to SASL_PLAINTEXT, SASL_SSL or SSL if writing to Kafka using some level of security. See below for additional info on secure setup.

more producer security props

If using SASL_PLAINTEXT, SASL_SSL or SSL refer to Kafka security for additional properties that need to be set on producer.

Other Kafka Producer Properties

 — 

These properties are used to configure the Kafka Producer. Any producer property supported by Kafka can be used. The only requirement is to prepend the property name with the prefix kafka.producer. For example: kafka.producer.linger.ms

Kafka Sink uses the topic and key properties from the FlumeEvent headers to send events to Kafka. If topic exists in the headers, the event will be sent to that specific topic, overriding the topic configured for the Sink. If key exists in the headers, the key will used by Kafka to partition the data between the topic partitions. Events with same key will be sent to the same partition. If the key is null, events will be sent to random partitions.

The Kafka sink also provides defaults for the key.serializer(org.apache.kafka.common.serialization.StringSerializer) and value.serializer(org.apache.kafka.common.serialization.ByteArraySerializer). Modification of these parameters is not recommended.

Deprecated Properties

Property Name Default Description

brokerList

 — 

Use kafka.bootstrap.servers

topic

default-flume-topic

Use kafka.topic

batchSize

100

Use kafka.flumeBatchSize

requiredAcks

1

Use kafka.producer.acks

An example configuration of a Kafka sink is given below. Properties starting with the prefix kafka.producer the Kafka producer. The properties that are passed when creating the Kafka producer are not limited to the properties given in this example. Also it is possible to include your custom properties here and access them inside the preprocessor through the Flume Context object passed in as a method argument.

  • Properties

  • YAML

  • JSON

a1.sinks.k1.channel = c1
a1.sinks.k1.type = org.apache.flume.sink.kafka.KafkaSink
a1.sinks.k1.kafka.topic = mytopic
a1.sinks.k1.kafka.bootstrap.servers = localhost:9092
a1.sinks.k1.kafka.flumeBatchSize = 20
a1.sinks.k1.kafka.producer.acks = 1
a1.sinks.k1.kafka.producer.linger.ms = 1
a1.sinks.k1.kafka.producer.compression.type = snappy
a1:
  sinks:
    k1:
      channel: c1
      type: org.apache.flume.sink.kafka.KafkaSink
      kafka:
        topic: mytopic
        bootstrap:
          servers: localhost:9092
        flumeBatchSize: 20
        producer:
          acks: 1
          linger:
            ms: 1
          compression:
            type: snappy
"a1": {
  "sinks": {
    "k1": {
      "channel": "c1",
      "type": "org.apache.flume.sink.kafka.KafkaSink",
      "kafka": {
        "topic": "mytopic",
        "bootstrap": {
          "servers": "localhost:9092"
        },
        "flumeBatchSize": 20,
        "producer": {
          "acks": 1,
          "linger": {
            "ms": 1
          },
          "compression": {
            "type": "snappy"
          }
        }
      }
    }
  }
}

Security and Kafka Sink:

Secure authentication as well as data encryption is supported on the communication channel between Flume and Kafka. For secure authentication SASL/GSSAPI (Kerberos V5) or SSL (even though the parameter is named SSL, the actual protocol is a TLS implementation) can be used from Kafka version 0.9.0.

As of now data encryption is solely provided by SSL/TLS.

Setting kafka.producer.security.protocol to any of the following value means:

  • SASL_PLAINTEXT - Kerberos or plaintext authentication with no data encryption

  • SASL_SSL - Kerberos or plaintext authentication with data encryption

  • SSL - TLS based encryption with optional authentication.

There is a performance degradation when SSL is enabled, the magnitude of which depends on the CPU type and the JVM implementation. Reference: Kafka security overview and the jira for tracking this issue: KAFKA-2561

TLS and Kafka Sink:

Please read the steps described in Configuring Kafka Clients SSL to learn about additional configuration settings for fine tuning for example any of the following: security provider, cipher suites, enabled protocols, truststore or keystore types.

Example configuration with server side authentication and data encryption.

  • Properties

  • YAML

  • JSON

a1.sinks.sink1.type = org.apache.flume.sink.kafka.KafkaSink
a1.sinks.sink1.kafka.bootstrap.servers = kafka-1:9093,kafka-2:9093,kafka-3:9093
a1.sinks.sink1.kafka.topic = mytopic
a1.sinks.sink1.kafka.producer.security.protocol = SSL
# optional, the global truststore can be used alternatively
a1.sinks.sink1.kafka.producer.ssl.truststore.location = /path/to/truststore.jks
a1.sinks.sink1.kafka.producer.ssl.truststore.password = <password to access the truststore>
a1:
  sinks:
    sink1:
      type: org.apache.flume.sink.kafka.KafkaSink
      kafka:
        bootstrap:
          servers: kafka-1:9093,kafka-2:9093,kafka-3:9093
        topic: mytopic
        producer:
          security:
            protocol: SSL
          ssl:
            truststore:
              # optional, the global truststore can be used alternatively
              location: /path/to/truststore.jks
              password: <password to access the truststore>
"a1": {
  "sinks": {
    "sink1": {
      "type": "org.apache.flume.sink.kafka.KafkaSink",
      "kafka": {
        "bootstrap": {
          "servers": "kafka-1:9093,kafka-2:9093,kafka-3:9093"
        },
        "topic": "mytopic",
        "producer": {
          "security": {
            "protocol": "SSL"
          },
          "ssl": {
            "truststore": {
              "location": "/path/to/truststore.jks",
              "password": "<password to access the truststore>"
            }
          }
        }
      }
    }
  }
}

Specyfing the truststore is optional here, the global truststore can be used instead. For more details about the global SSL setup, see the SSL/TLS support section.

Note: By default the property ssl.endpoint.identification.algorithm is not defined, so hostname verification is not performed. In order to enable hostname verification, set the following properties

  • Properties

  • YAML

  • JSON

a1.sinks.sink1.kafka.producer.ssl.endpoint.identification.algorithm = HTTPS
a1:
  sinks:
    sink1:
      kafka:
        producer:
          ssl:
            endpoint:
              identification:
                algorithm: HTTPS
"a1": {
  "sinks": {
    "sink1": {
      "kafka": {
        "producer": {
          "ssl": {
            "endpoint": {
              "identification": {
                "algorithm": "HTTPS"
              }
            }
          }
        }
      }
    }
  }
}

Once enabled, clients will verify the server’s fully qualified domain name (FQDN) against one of the following two fields:

If client side authentication is also required then additionally the following needs to be added to Flume agent configuration or the global SSL setup can be used (see SSL/TLS support section). Each Flume agent has to have its client certificate which has to be trusted by Kafka brokers either individually or by their signature chain. Common example is to sign each client certificate by a single Root CA which in turn is trusted by Kafka brokers.

  • Properties

  • YAML

  • JSON

# optional, the global keystore can be used alternatively
a1.sinks.sink1.kafka.producer.ssl.keystore.location = /path/to/client.keystore.jks
a1.sinks.sink1.kafka.producer.ssl.keystore.password = <password to access the keystore>
# optional, the global keystore can be used alternatively
a1:
  sinks:
    sink1:
      kafka:
        producer:
          ssl:
            keystore:
              location: /path/to/client.keystore.jks
              password: <password to access the keystore>
"a1": {
  "sinks": {
    "sink1": {
      "kafka": {
        "producer": {
          "ssl": {
            "keystore": {
              "location": "/path/to/client.keystore.jks",
              "password": "<password to access the keystore>"
            }
          }
        }
      }
    }
  }
}

If keystore and key use different password protection then ssl.key.password property will provide the required additional secret for producer keystore:

  • Properties

  • YAML

  • JSON

a1.sinks.sink1.kafka.producer.ssl.key.password = <password to access the key>
a1:
  sinks:
    sink1:
      kafka:
        producer:
          ssl:
            key:
              password: <password to access the key>
"a1": {
  "sinks": {
    "sink1": {
      "kafka": {
        "producer": {
          "ssl": {
            "key": {
              "password": "<password to access the key>"
            }
          }
        }
      }
    }
  }
}

Kerberos and Kafka Sink:

To use Kafka sink with a Kafka cluster secured with Kerberos, set the producer.security.protocol property noted above for producer. The Kerberos keytab and principal to be used with Kafka brokers is specified in a JAAS file’s "KafkaClient" section. "Client" section describes the Zookeeper connection if needed. See Kafka doc for information on the JAAS file contents. The location of this JAAS file and optionally the system wide kerberos configuration can be specified via JAVA_OPTS in flume-env.sh:

JAVA_OPTS="$JAVA_OPTS -Djava.security.krb5.conf=/path/to/krb5.conf"
JAVA_OPTS="$JAVA_OPTS -Djava.security.auth.login.config=/path/to/flume_jaas.conf"

Example secure configuration using SASL_PLAINTEXT:

  • Properties

  • YAML

  • JSON

a1.sinks.sink1.type = org.apache.flume.sink.kafka.KafkaSink
a1.sinks.sink1.kafka.bootstrap.servers = kafka-1:9093,kafka-2:9093,kafka-3:9093
a1.sinks.sink1.kafka.topic = mytopic
a1.sinks.sink1.kafka.producer.security.protocol = SASL_PLAINTEXT
a1.sinks.sink1.kafka.producer.sasl.mechanism = GSSAPI
a1.sinks.sink1.kafka.producer.sasl.kerberos.service.name = kafka
a1:
  sinks:
    sink1:
      type: org.apache.flume.sink.kafka.KafkaSink
      kafka:
        bootstrap:
          servers: kafka-1:9093,kafka-2:9093,kafka-3:9093
        topic: mytopic
        producer:
          security:
            protocol: SASL_PLAINTEXT
          sasl:
            mechanism: GSSAPI
            kerberos:
              service:
                name: kafka
"a1": {
  "sinks": {
    "sink1": {
      "type": "org.apache.flume.sink.kafka.KafkaSink",
      "kafka": {
        "bootstrap": {
          "servers": "kafka-1:9093,kafka-2:9093,kafka-3:9093"
        },
        "topic": "mytopic",
        "producer": {
          "security": {
            "protocol": "SASL_PLAINTEXT"
          },
          "sasl": {
            "mechanism": "GSSAPI",
            "kerberos": {
              "service": {
                "name": "kafka"
              }
            }
          }
        }
      }
    }
  }
}

Example secure configuration using SASL_SSL:

  • Properties

  • YAML

  • JSON

a1.sinks.sink1.type = org.apache.flume.sink.kafka.KafkaSink
a1.sinks.sink1.kafka.bootstrap.servers = kafka-1:9093,kafka-2:9093,kafka-3:9093
a1.sinks.sink1.kafka.topic = mytopic
a1.sinks.sink1.kafka.producer.security.protocol = SASL_SSL
a1.sinks.sink1.kafka.producer.sasl.mechanism = GSSAPI
a1.sinks.sink1.kafka.producer.sasl.kerberos.service.name = kafka
# optional, the global truststore can be used alternatively
a1.sinks.sink1.kafka.producer.ssl.truststore.location = /path/to/truststore.jks
a1.sinks.sink1.kafka.producer.ssl.truststore.password = <password to access the truststore>
a1:
  sinks:
    sink1:
      type: org.apache.flume.sink.kafka.KafkaSink
      kafka:
        bootstrap:
          servers: kafka-1:9093,kafka-2:9093,kafka-3:9093
        topic: mytopic
        producer:
          security:
            protocol: SASL_SSL
          sasl:
            mechanism: GSSAPI
            kerberos:
              service:
                name: kafka
          ssl:
            truststore:
              # optional, the global truststore can be used alternatively
              location: /path/to/truststore.jks
              password: <password to access the truststore>
"a1": {
  "sinks": {
    "sink1": {
      "type": "org.apache.flume.sink.kafka.KafkaSink",
      "kafka": {
        "bootstrap": {
          "servers": "kafka-1:9093,kafka-2:9093,kafka-3:9093"
        },
        "topic": "mytopic",
        "producer": {
          "security": {
            "protocol": "SASL_SSL"
          },
          "sasl": {
            "mechanism": "GSSAPI",
            "kerberos": {
              "service": {
                "name": "kafka"
              }
            }
          },
          "ssl": {
            "truststore": {
              "location": "/path/to/truststore.jks",
              "password": "<password to access the truststore>"
            }
          }
        }
      }
    }
  }
}

Sample JAAS file. For reference of its content please see client config sections of the desired authentication mechanism (GSSAPI/PLAIN) in Kafka documentation of SASL configuration. Unlike the Kafka Source or Kafka Channel a "Client" section is not required, unless it is needed by other connecting components. Also please make sure that the operating system user of the Flume processes has read privileges on the jaas and keytab files.

KafkaClient {
  com.sun.security.auth.module.Krb5LoginModule required
  useKeyTab=true
  storeKey=true
  keyTab="/path/to/keytabs/flume.keytab"
  principal="flume/flumehost1.example.com@YOURKERBEROSREALM";
};

Kafka Channel

The events are stored in a Kafka cluster (must be installed separately). Kafka provides high availability and replication, so in case an agent or a kafka broker crashes, the events are immediately available to other sinks

The Kafka channel can be used for multiple scenarios:

  1. With Flume source and sink - it provides a reliable and highly available channel for events

  2. With Flume source and interceptor but no sink - it allows writing Flume events into a Kafka topic, for use by other apps

  3. With Flume sink, but no source - it is a low-latency, fault tolerant way to send events from Kafka to Flume sinks such as HDFS, HBase or Solr

This currently supports Kafka server releases 0.10.1.0 or higher. Testing was done up to 2.0.1 that was the highest avilable version at the time of the release.

The configuration parameters are organized as such:

  1. Configuration values related to the channel generically are applied at the channel config level, eg: a1.channel.k1.type =

  2. Configuration values related to Kafka or how the Channel operates are prefixed with "kafka.", (this are analgous to CommonClient Configs) eg: a1.channels.k1.kafka.topic and a1.channels.k1.kafka.bootstrap.servers. This is not dissimilar to how the hdfs sink operates

  3. Properties specific to the producer/consumer are prefixed by kafka.producer or kafka.consumer

  4. Where possible, the Kafka paramter names are used, eg: bootstrap.servers and acks

This version of flume is backwards-compatible with previous versions, however deprecated properties are indicated in the table below and a warning message is logged on startup when they are present in the configuration file.

Required properties are in bold.

Property Name Default Description

type

 — 

The component type name, needs to be org.apache.flume.channel.kafka.KafkaChannel

kafka.bootstrap.servers

 — 

List of brokers in the Kafka cluster used by the channel This can be a partial list of brokers, but we recommend at least two for HA. The format is comma separated list of hostname:port

kafka.topic

flume-channel

Kafka topic which the channel will use

kafka.consumer.group.id

flume

Consumer group ID the channel uses to register with Kafka. Multiple channels must use the same topic and group to ensure that when one agent fails another can get the data Note that having non-channel consumers with the same ID can lead to data loss.

parseAsFlumeEvent

true

Expecting Avro datums with FlumeEvent schema in the channel. This should be true if Flume source is writing to the channel and false if other producers are writing into the topic that the channel is using. Flume source messages to Kafka can be parsed outside of Flume by using org.apache.flume.source.avro.AvroFlumeEvent provided by the flume-avro-client artifact

pollTimeout

500

The amount of time(in milliseconds) to wait in the "poll()" call of the consumer. https://kafka.apache.org/090/javadoc/org/apache/kafka/clients/consumer/KafkaConsumer.html#poll(long)

defaultPartitionId

 — 

Specifies a Kafka partition ID (integer) for all events in this channel to be sent to, unless overriden by partitionIdHeader. By default, if this property is not set, events will be distributed by the Kafka Producer’s partitioner - including by key if specified (or by a partitioner specified by kafka.partitioner.class).

partitionIdHeader

 — 

When set, the producer will take the value of the field named using the value of this property from the event header and send the message to the specified partition of the topic. If the value represents an invalid partition the event will not be accepted into the channel. If the header value is present then this setting overrides defaultPartitionId.

kafka.consumer.auto.offset.reset

latest

What to do when there is no initial offset in Kafka or if the current offset does not exist any more on the server (e.g. because that data has been deleted): earliest: automatically reset the offset to the earliest offset latest: automatically reset the offset to the latest offset none: throw exception to the consumer if no previous offset is found for the consumer’s group anything else: throw exception to the consumer.

kafka.producer.security.protocol

PLAINTEXT

Set to SASL_PLAINTEXT, SASL_SSL or SSL if writing to Kafka using some level of security. See below for additional info on secure setup.

kafka.consumer.security.protocol

PLAINTEXT

Same as kafka.producer.security.protocol but for reading/consuming from Kafka.

more producer/consumer security props

If using SASL_PLAINTEXT, SASL_SSL or SSL refer to Kafka security for additional properties that need to be set on producer/consumer.

Deprecated Properties

Property Name Default Description

brokerList

 — 

List of brokers in the Kafka cluster used by the channel This can be a partial list of brokers, but we recommend at least two for HA. The format is comma separated list of hostname:port

topic

flume-channel

Use kafka.topic

groupId

flume

Use kafka.consumer.group.id

readSmallestOffset

false

Use kafka.consumer.auto.offset.reset

migrateZookeeperOffsets

true

When no Kafka stored offset is found, look up the offsets in Zookeeper and commit them to Kafka. This should be true to support seamless Kafka client migration from older versions of Flume. Once migrated this can be set to false, though that should generally not be required. If no Zookeeper offset is found the kafka.consumer.auto.offset.reset configuration defines how offsets are handled.

Due to the way the channel is load balanced, there may be duplicate events when the agent first starts up

Example for agent named a1:

  • Properties

  • YAML

  • JSON

a1.channels.channel1.type = org.apache.flume.channel.kafka.KafkaChannel
a1.channels.channel1.kafka.bootstrap.servers = kafka-1:9092,kafka-2:9092,kafka-3:9092
a1.channels.channel1.kafka.topic = channel1
a1.channels.channel1.kafka.consumer.group.id = flume-consumer
a1:
  channels:
    channel1:
      type: org.apache.flume.channel.kafka.KafkaChannel
      kafka:
        bootstrap:
          servers: kafka-1:9092,kafka-2:9092,kafka-3:9092
        topic: channel1
        consumer:
          group:
            id: flume-consumer
"a1": {
  "channels": {
    "channel1": {
      "type": "org.apache.flume.channel.kafka.KafkaChannel",
      "kafka": {
        "bootstrap": {
          "servers": "kafka-1:9092,kafka-2:9092,kafka-3:9092"
        },
        "topic": "channel1",
        "consumer": {
          "group": {
            "id": "flume-consumer"
          }
        }
      }
    }
  }
}

Security and Kafka Channel:

Secure authentication as well as data encryption is supported on the communication channel between Flume and Kafka. For secure authentication SASL/GSSAPI (Kerberos V5) or SSL (even though the parameter is named SSL, the actual protocol is a TLS implementation) can be used from Kafka version 0.9.0.

As of now data encryption is solely provided by SSL/TLS.

Setting kafka.producer|consumer.security.protocol to any of the following value means:

  • SASL_PLAINTEXT - Kerberos or plaintext authentication with no data encryption

  • SASL_SSL - Kerberos or plaintext authentication with data encryption

  • SSL - TLS based encryption with optional authentication.

There is a performance degradation when SSL is enabled, the magnitude of which depends on the CPU type and the JVM implementation. Reference: Kafka security overview and the jira for tracking this issue: KAFKA-2561

TLS and Kafka Channel:

Please read the steps described in Configuring Kafka Clients SSL to learn about additional configuration settings for fine tuning for example any of the following: security provider, cipher suites, enabled protocols, truststore or keystore types.

Example configuration with server side authentication and data encryption.

  • Properties

  • YAML

  • JSON

a1.channels.channel1.type = org.apache.flume.channel.kafka.KafkaChannel
a1.channels.channel1.kafka.bootstrap.servers = kafka-1:9093,kafka-2:9093,kafka-3:9093
a1.channels.channel1.kafka.topic = channel1
a1.channels.channel1.kafka.consumer.group.id = flume-consumer
a1.channels.channel1.kafka.producer.security.protocol = SSL
# optional, the global truststore can be used alternatively
a1.channels.channel1.kafka.producer.ssl.truststore.location = /path/to/truststore.jks
a1.channels.channel1.kafka.producer.ssl.truststore.password = <password to access the truststore>
a1.channels.channel1.kafka.consumer.security.protocol = SSL
# optional, the global truststore can be used alternatively
a1.channels.channel1.kafka.consumer.ssl.truststore.location = /path/to/truststore.jks
a1.channels.channel1.kafka.consumer.ssl.truststore.password = <password to access the truststore>
a1:
  channels:
    channel1:
      type: org.apache.flume.channel.kafka.KafkaChannel
      kafka:
        bootstrap:
          servers: kafka-1:9093,kafka-2:9093,kafka-3:9093
        topic: channel1
        consumer:
          group:
            id: flume-consumer
          security:
            protocol: SSL
          ssl:
            truststore:
              # optional, the global truststore can be used alternatively
              location: /path/to/truststore.jks
              password: <password to access the truststore>
        producer:
          security:
            protocol: SSL
          ssl:
            truststore:
              # optional, the global truststore can be used alternatively
              location: /path/to/truststore.jks
              password: <password to access the truststore>
"a1": {
  "channels": {
    "channel1": {
      "type": "org.apache.flume.channel.kafka.KafkaChannel",
      "kafka": {
        "bootstrap": {
          "servers": "kafka-1:9093,kafka-2:9093,kafka-3:9093"
        },
        "topic": "channel1",
        "consumer": {
          "group": {
            "id": "flume-consumer"
          },
          "security": {
            "protocol": "SSL"
          },
          "ssl": {
            "truststore": {
              "location": "/path/to/truststore.jks",
              "password": "<password to access the truststore>"
            }
          }
        },
        "producer": {
          "security": {
            "protocol": "SSL"
          },
          "ssl": {
            "truststore": {
              "location": "/path/to/truststore.jks",
              "password": "<password to access the truststore>"
            }
          }
        }
      }
    }
  }
}

Specyfing the truststore is optional here, the global truststore can be used instead. For more details about the global SSL setup, see the SSL/TLS support section.

Note: By default the property ssl.endpoint.identification.algorithm is not defined, so hostname verification is not performed. In order to enable hostname verification, set the following properties

  • Properties

  • YAML

  • JSON

a1.channels.channel1.kafka.producer.ssl.endpoint.identification.algorithm = HTTPS
a1.channels.channel1.kafka.consumer.ssl.endpoint.identification.algorithm = HTTPS
a1:
  channels:
    channel1:
      kafka:
        producer:
          ssl:
            endpoint:
              identification:
                algorithm: HTTPS
        consumer:
          ssl:
            endpoint:
              identification:
                algorithm: HTTPS
"a1": {
  "channels": {
    "channel1": {
      "kafka": {
        "producer": {
          "ssl": {
            "endpoint": {
              "identification": {
                "algorithm": "HTTPS"
              }
            }
          }
        },
        "consumer": {
          "ssl": {
            "endpoint": {
              "identification": {
                "algorithm": "HTTPS"
              }
            }
          }
        }
      }
    }
  }
}

Once enabled, clients will verify the server’s fully qualified domain name (FQDN) against one of the following two fields:

If client side authentication is also required then additionally the following needs to be added to Flume agent configuration or the global SSL setup can be used (see SSL/TLS support section). Each Flume agent has to have its client certificate which has to be trusted by Kafka brokers either individually or by their signature chain. Common example is to sign each client certificate by a single Root CA which in turn is trusted by Kafka brokers.

  • Properties

  • YAML

  • JSON

# optional, the global keystore can be used alternatively
a1.channels.channel1.kafka.producer.ssl.keystore.location = /path/to/client.keystore.jks
a1.channels.channel1.kafka.producer.ssl.keystore.password = <password to access the keystore>
# optional, the global keystore can be used alternatively
a1.channels.channel1.kafka.consumer.ssl.keystore.location = /path/to/client.keystore.jks
a1.channels.channel1.kafka.consumer.ssl.keystore.password = <password to access the keystore>
# optional, the global keystore can be used alternatively
a1:
  channels:
    channel1:
      kafka:
        producer:
          ssl:
            keystore:
              location: /path/to/client.keystore.jks
              password: <password to access the keystore>
        consumer:
          ssl:
            keystore:
              # optional, the global keystore can be used alternatively
              location: /path/to/client.keystore.jks
              password: <password to access the keystore>
"a1": {
  "channels": {
    "channel1": {
      "kafka": {
        "producer": {
          "ssl": {
            "keystore": {
              "location": "/path/to/client.keystore.jks",
              "password": "<password to access the keystore>"
            }
          }
        },
        "consumer": {
          "ssl": {
            "keystore": {
              "location": "/path/to/client.keystore.jks",
              "password": "<password to access the keystore>"
            }
          }
        }
      }
    }
  }
}

If keystore and key use different password protection then ssl.key.password property will provide the required additional secret for both consumer and producer keystores:

  • Properties

  • YAML

  • JSON

a1.channels.channel1.kafka.producer.ssl.key.password = <password to access the key>
a1.channels.channel1.kafka.consumer.ssl.key.password = <password to access the key>
a1:
  channels:
    channel1:
      kafka:
        producer:
          ssl:
            key:
              password: <password to access the key>
        consumer:
          ssl:
            key:
              password: <password to access the key>
"a1": {
  "channels": {
    "channel1": {
      "kafka": {
        "producer": {
          "ssl": {
            "key": {
              "password": "<password to access the key>"
            }
          }
        },
        "consumer": {
          "ssl": {
            "key": {
              "password": "<password to access the key>"
            }
          }
        }
      }
    }
  }
}

Kerberos and Kafka Channel:

To use Kafka channel with a Kafka cluster secured with Kerberos, set the producer/consumer.security.protocol properties noted above for producer and/or consumer. The Kerberos keytab and principal to be used with Kafka brokers is specified in a JAAS file’s "KafkaClient" section. "Client" section describes the Zookeeper connection if needed. See Kafka doc for information on the JAAS file contents. The location of this JAAS file and optionally the system wide kerberos configuration can be specified via JAVA_OPTS in flume-env.sh:

JAVA_OPTS="$JAVA_OPTS -Djava.security.krb5.conf=/path/to/krb5.conf"
JAVA_OPTS="$JAVA_OPTS -Djava.security.auth.login.config=/path/to/flume_jaas.conf"

Example secure configuration using SASL_PLAINTEXT:

  • Properties

  • YAML

  • JSON

a1.channels.channel1.type = org.apache.flume.channel.kafka.KafkaChannel
a1.channels.channel1.kafka.bootstrap.servers = kafka-1:9093,kafka-2:9093,kafka-3:9093
a1.channels.channel1.kafka.topic = channel1
a1.channels.channel1.kafka.consumer.group.id = flume-consumer
a1.channels.channel1.kafka.producer.security.protocol = SASL_PLAINTEXT
a1.channels.channel1.kafka.producer.sasl.mechanism = GSSAPI
a1.channels.channel1.kafka.producer.sasl.kerberos.service.name = kafka
a1.channels.channel1.kafka.consumer.security.protocol = SASL_PLAINTEXT
a1.channels.channel1.kafka.consumer.sasl.mechanism = GSSAPI
a1.channels.channel1.kafka.consumer.sasl.kerberos.service.name = kafka
a1:
  channels:
    channel1:
      type: org.apache.flume.channel.kafka.KafkaChannel
      kafka:
        bootstrap:
          servers: kafka-1:9093,kafka-2:9093,kafka-3:9093
        topic: channel1
        consumer:
          group:
            id: flume-consumer
          security:
            protocol: SASL_PLAINTEXT
          sasl:
            mechanism: GSSAPI
            kerberos:
              service:
                name: kafka
        producer:
          security:
            protocol: SASL_PLAINTEXT
          sasl:
            mechanism: GSSAPI
            kerberos:
              service:
                name: kafka
"a1": {
  "channels": {
    "channel1": {
      "type": "org.apache.flume.channel.kafka.KafkaChannel",
      "kafka": {
        "bootstrap": {
          "servers": "kafka-1:9093,kafka-2:9093,kafka-3:9093"
        },
        "topic": "channel1",
        "consumer": {
          "group": {
            "id": "flume-consumer"
          },
          "security": {
            "protocol": "SASL_PLAINTEXT"
          },
          "sasl": {
            "mechanism": "GSSAPI",
            "kerberos": {
              "service": {
                "name": "kafka"
              }
            }
          }
        },
        "producer": {
          "security": {
            "protocol": "SASL_PLAINTEXT"
          },
          "sasl": {
            "mechanism": "GSSAPI",
            "kerberos": {
              "service": {
                "name": "kafka"
              }
            }
          }
        }
      }
    }
  }
}

Example secure configuration using SASL_SSL:

  • Properties

  • YAML

  • JSON

a1.channels.channel1.type = org.apache.flume.channel.kafka.KafkaChannel
a1.channels.channel1.kafka.bootstrap.servers = kafka-1:9093,kafka-2:9093,kafka-3:9093
a1.channels.channel1.kafka.topic = channel1
a1.channels.channel1.kafka.consumer.group.id = flume-consumer
a1.channels.channel1.kafka.producer.security.protocol = SASL_SSL
a1.channels.channel1.kafka.producer.sasl.mechanism = GSSAPI
a1.channels.channel1.kafka.producer.sasl.kerberos.service.name = kafka
# optional, the global truststore can be used alternatively
a1.channels.channel1.kafka.producer.ssl.truststore.location = /path/to/truststore.jks
a1.channels.channel1.kafka.producer.ssl.truststore.password = <password to access the truststore>
a1.channels.channel1.kafka.consumer.security.protocol = SASL_SSL
a1.channels.channel1.kafka.consumer.sasl.mechanism = GSSAPI
a1.channels.channel1.kafka.consumer.sasl.kerberos.service.name = kafka
# optional, the global truststore can be used alternatively
a1.channels.channel1.kafka.consumer.ssl.truststore.location = /path/to/truststore.jks
a1.channels.channel1.kafka.consumer.ssl.truststore.password = <password to access the truststore>
a1:
  channels:
    channel1:
      type: org.apache.flume.channel.kafka.KafkaChannel
      kafka:
        bootstrap:
          servers: kafka-1:9093,kafka-2:9093,kafka-3:9093
        topic: channel1
        consumer:
          group:
            id: flume-consumer
          security:
            protocol: SASL_SSL
          sasl:
            mechanism: GSSAPI
            kerberos:
              service:
                name: kafka
          ssl:
            truststore:
              # optional, the global truststore can be used alternatively
              location: /path/to/truststore.jks
              password: <password to access the truststore>
        producer:
          security:
            protocol: SASL_SSL
          sasl:
            mechanism: GSSAPI
            kerberos:
              service:
                name: kafka
          ssl:
            truststore:
              # optional, the global truststore can be used alternatively
              location: /path/to/truststore.jks
              password: <password to access the truststore>
"a1": {
  "channels": {
    "channel1": {
      "type": "org.apache.flume.channel.kafka.KafkaChannel",
      "kafka": {
        "bootstrap": {
          "servers": "kafka-1:9093,kafka-2:9093,kafka-3:9093"
        },
        "topic": "channel1",
        "consumer": {
          "group": {
            "id": "flume-consumer"
          },
          "security": {
            "protocol": "SASL_SSL"
          },
          "sasl": {
            "mechanism": "GSSAPI",
            "kerberos": {
              "service": {
                "name": "kafka"
              }
            }
          },
          "ssl": {
            "truststore": {
              "location": "/path/to/truststore.jks",
              "password": "<password to access the truststore>"
            }
          }
        },
        "producer": {
          "security": {
            "protocol": "SASL_SSL"
          },
          "sasl": {
            "mechanism": "GSSAPI",
            "kerberos": {
              "service": {
                "name": "kafka"
              }
            }
          },
          "ssl": {
            "truststore": {
              "location": "/path/to/truststore.jks",
              "password": "<password to access the truststore>"
            }
          }
        }
      }
    }
  }
}

Sample JAAS file. For reference of its content please see client config sections of the desired authentication mechanism (GSSAPI/PLAIN) in Kafka documentation of SASL configuration. Since the Kafka Source may also connect to Zookeeper for offset migration, the "Client" section was also added to this example. This won’t be needed unless you require offset migration, or you require this section for other secure components. Also please make sure that the operating system user of the Flume processes has read privileges on the jaas and keytab files.

Client {
  com.sun.security.auth.module.Krb5LoginModule required
  useKeyTab=true
  storeKey=true
  keyTab="/path/to/keytabs/flume.keytab"
  principal="flume/flumehost1.example.com@YOURKERBEROSREALM";
};

KafkaClient {
  com.sun.security.auth.module.Krb5LoginModule required
  useKeyTab=true
  storeKey=true
  keyTab="/path/to/keytabs/flume.keytab"
  principal="flume/flumehost1.example.com@YOURKERBEROSREALM";
};