General availability (GA) Open source

otelcol.exporter.kafka

otelcol.exporter.kafka accepts logs, metrics, and traces telemetry data from other otelcol components and sends it to Kafka.

It’s important to use otelcol.exporter.kafka together with otelcol.processor.batch to make sure otelcol.exporter.kafka doesn’t slow down due to sending Kafka a huge number of small payloads.

Note

otelcol.exporter.kafka is a wrapper over the upstream OpenTelemetry Collector kafka exporter. Bug reports or feature requests will be redirected to the upstream repository, if necessary.

Multiple otelcol.exporter.kafka components can be specified by giving them different labels.

Usage

Alloy
otelcol.exporter.kafka "LABEL" {
  protocol_version = "PROTOCOL_VERSION"
}

Arguments

You can use the following arguments with otelcol.exporter.kafka:

NameTypeDescriptionDefaultRequired
protocol_versionstringKafka protocol version to use.yes
brokerslist(string)Kafka brokers to connect to.["localhost:9092"]no
allow_auto_topic_creationboolWhether to allow automatic topic creation.trueno
client_idstringConsumer client ID to use. The ID will be used for all produce requests."otel-collector"no
conn_idle_timeoutdurationTime after which idle connections are not reused and may be closed."9m"no
encodingstring(Deprecated) Encoding of payload read from Kafka."otlp_proto"no
include_metadata_keyslist(string)List of metadata keys to propagate as Kafka message headers.[]no
partition_metrics_by_resource_attributesboolWhether to include the hash of sorted resource attributes as the message partitioning key in metric messages sent to Kafka.falseno
partition_logs_by_resource_attributesboolWhether to include the hash of sorted resource attributes as the message partitioning key in log messages sent to Kafka.falseno
partition_logs_by_trace_idboolWhether to use the 16-bit hex string of the trace ID as the message partitioning key in log messages sent to Kafka.falseno
partition_traces_by_idboolWhether to include the trace ID as the message key in trace messages sent to Kafka.falseno
resolve_canonical_bootstrap_servers_onlyboolWhether to resolve then reverse-lookup broker IP addresses during startup. Deprecated: now a no-op after the upstream Kafka client migration from sarama to franz-go.falseno
signal_headerboolWhether to add an otelcol.signal header identifying the signal type to every outgoing Kafka record.falseno
timeoutdurationThe timeout for every attempt to send data to the backend."5s"no
topic_from_attributestringA resource attribute whose value should be used as the message’s topic.""no
topicstring(Deprecated) Kafka topic to send to.See belowno

Warning

The topic and encoding arguments are deprecated in favor of the logs, metrics, and traces blocks.

When topic_from_metadata_key is set in a signal-specific block, it will take precedence over topic_from_attribute and topic arguments. When topic_from_attribute is set, it will take precedence over the topic arguments in logs, metrics, and traces blocks.

partition_traces_by_id doesn’t have any effect on Jaeger encoding exporters since Jaeger exporters include trace ID as the message key by default.

partition_logs_by_resource_attributes and partition_logs_by_trace_id are mutually exclusive and can’t both be true.

include_metadata_keys specifies metadata keys to propagate as Kafka message headers. If one or more keys aren’t found in the metadata, they are ignored. The keys also partition the data before export if sending_queue.batch is defined.

When signal_header is true, the otelcol.signal header key is reserved: it’s an error to also include it in include_metadata_keys.

Blocks

You can use the following blocks with otelcol.exporter.kafka:

logs

The logs block configures how to send logs to Kafka brokers.

NameTypeDescriptionDefaultRequired
encodingstringThe encoding for logs. Refer to Supported encodings."otlp_proto"no
message_key_from_metadata_keystringThe name of the metadata key whose value should be used as the message’s key. Mutually exclusive with partition_logs_by_resource_attributes and partition_logs_by_trace_id.""no
topicstringThe name of the Kafka topic to which logs will be exported."otlp_logs"no
topic_from_metadata_keystringThe name of the metadata key whose value should be used as the message’s topic. Takes precedence over topic_from_attribute and topic settings.""no

metrics

The metrics block configures how to send metrics to Kafka brokers.

NameTypeDescriptionDefaultRequired
encodingstringThe encoding for metrics. Refer to Supported encodings."otlp_proto"no
message_key_from_metadata_keystringThe name of the metadata key whose value should be used as the message’s key. Mutually exclusive with partition_metrics_by_resource_attributes.""no
topicstringThe name of the Kafka topic to which metrics will be exported."otlp_metrics"no
topic_from_metadata_keystringThe name of the metadata key whose value should be used as the message’s topic. Takes precedence over topic_from_attribute and topic settings.""no

traces

The traces block configures how to send traces to Kafka brokers.

NameTypeDescriptionDefaultRequired
encodingstringThe encoding for traces. Refer to Supported encodings."otlp_proto"no
message_key_from_metadata_keystringThe name of the metadata key whose value should be used as the message’s key. Mutually exclusive with partition_traces_by_id.""no
topicstringThe name of the Kafka topic to which traces will be exported."otlp_spans"no
topic_from_metadata_keystringThe name of the metadata key whose value should be used as the message’s topic. Takes precedence over topic_from_attribute and topic settings.""no

authentication

The authentication block holds the definition of different authentication mechanisms to use when connecting to Kafka brokers. It doesn’t support any arguments and is configured fully through inner blocks.

The sasl and kerberos blocks are mutually exclusive; configuring both is rejected.

kerberos

The kerberos block configures Kerberos authentication against the Kafka broker.

The following arguments are supported:

NameTypeDescriptionDefaultRequired
config_filestringPath to Kerberos location, for example, /etc/krb5.conf.no
disable_fast_negotiationboolDisable PA-FX-FAST negotiation.falseno
keytab_filestringPath to keytab file, for example, /etc/security/kafka.keytab.no
passwordsecretKerberos password to authenticate with.no
realmstringKerberos realm.no
service_namestringKerberos service name.no
use_keytabstringEnables using keytab instead of password.no
usernamestringKerberos username to authenticate as.yes

When use_keytab is false, the password argument is required. When use_keytab is true, the file pointed to by the keytab_file argument is used for authentication instead. At most one of password or keytab_file must be provided.

disable_fast_negotiation is useful for Kerberos implementations which don’t support PA-FX-FAST (Pre-Authentication Framework - Fast) negotiation.

plaintext

Caution

The plaintext block has been deprecated. Use sasl with mechanism set to PLAIN instead.

The plaintext block configures plain text authentication against Kafka brokers.

The following arguments are supported:

NameTypeDescriptionDefaultRequired
passwordsecretPassword to use for plain text authentication.yes
usernamestringUsername to use for plain text authentication.yes

sasl

The sasl block configures SASL authentication against Kafka brokers.

The following arguments are supported:

NameTypeDescriptionDefaultRequired
mechanismstringSASL mechanism to use when authenticating.yes
passwordsecretPassword to use for SASL authentication.yes
usernamestringUsername to use for SASL authentication.yes
versionnumber(Deprecated) Version of the SASL Protocol to use when authenticating.0no

You can set the mechanism argument to one of the following strings:

  • "PLAIN"
  • "SCRAM-SHA-256"
  • "SCRAM-SHA-512"
  • "AWS_MSK_IAM_OAUTHBEARER"

When mechanism is set to "AWS_MSK_IAM_OAUTHBEARER", the aws_msk child block must also be provided.

version has been deprecated. The client negotiates the SASL handshake version automatically; setting version doesn’t produce an error, but has no effect.

aws_msk

The aws_msk block configures extra parameters for SASL authentication when using the AWS_MSK_IAM_OAUTHBEARER mechanisms.

The following arguments are supported:

NameTypeDescriptionDefaultRequired
regionstring