Using Kafka as a buffer between OpenTelemetry Collectors

Kafka between agent and gateway Collectors can absorb back-end outages and allow replay, but it adds a stateful cluster to run. This page covers when to use it, how the exporter and receiver are configured, and when a persistent queue is enough.

On this page

When Kafka as a buffer between OpenTelemetry Collectors is worth running

Kafka is an optional buffer between OpenTelemetry Collectors, not a requirement for running OpenTelemetry. If your back end has outages that last longer than your Collector queues can hold data, or if you need to replay telemetry into a back end after an incident, a Kafka topic between the two tiers can absorb the gap. The Collector runs in two common roles: an agent next to workloads that receives and forwards telemetry, and a gateway that accepts data from many agents and exports it to the back end. Kafka usually sits between the agent or first-tier gateway and the second-tier gateway. On the sending side, the Kafka exporter writes traces, metrics and logs to topics; on the receiving side, the Kafka receiver reads them back. Both components are beta for their signals, so check the current status of each signal in the Kafka exporter README before you commit.

Kafka is a separate distributed system with its own operating burden. You will need to size brokers, plan partitions and retention, secure client and broker traffic, and keep the cluster upgraded. Apache Kafka is licensed under Apache-2.0, so the software has no license fee, but the people, infrastructure and support you need to run it are real costs. Before you decide, confirm whether your existing Collector sending queues and file-backed persistent storage already cover your outage windows. If they do, a Kafka cluster adds operational risk without solving a new problem. Kafka earns its place when telemetry volume is high enough that disk-backed Collector queues fill too fast, when several independent consumers need the same stream, or when your organization already runs Kafka and has the skills to operate it.

The decision comes down to three questions for your team. How long must telemetry survive a back-end outage, and how much data does one hour of that outage represent? Who will own the Kafka cluster after go-live, and do they have the time to patch and monitor it? Will other systems read the same telemetry stream? Write the answers down, then compare the outage window against the queue capacity you can configure in the Collector. Ask any partner quoting this work to scope cluster sizing, security settings and a replay runbook separately, so you can see which costs come from the Collector side and which come from the Kafka side.

How telemetry flows through Kafka between agent and gateway Collectors

The flow starts in applications that send telemetry to an agent Collector in the application network zone. The agent's Kafka exporter writes to Kafka topics in the broker zone, which sits behind the trust boundary. Gateway Collectors read those topics with the Kafka receiver and export to the back end. Check that the broker's TLS and SASL settings match on both sides, and that the gateway's consumer group reads everything the agents write.

Telemetry path from agent Collectors through Kafka to gateway Collectors and the back end.

Deciding between a persistent queue and Kafka

A persistent queue inside the Collector and a Kafka cluster both keep telemetry through a back-end outage, but they differ in how long they can hold data, who can read it again, and who must run them. The cards below cover the six criteria that usually settle the choice for a given team.

Outage duration to survive

Start with the longest back-end outage the team must ride out without losing data. A Collector sending queue on local disk is bounded by the node's disk and the Collector's own restart behavior, while Kafka holds data on brokers for a retention period you configure. Write the required outage window down before comparing options, and confirm disk capacity on each agent or gateway that would hold the queue.

Collector configuration docs

Replay by multiple consumers

Kafka lets several consumer groups read the same topic at their own pace, so a second back end, a data lake or an analytics job can take telemetry without changing the Collectors. A file-backed queue is drained once by the Collector that owns it. If you expect more than one reader, or need to replay data into a new back end later, Kafka is the stronger fit. Confirm this need with the teams that would consume the data.

Existing Kafka operations skill

Running Kafka well means owning brokers, partitions, retention, storage growth, upgrades and access control. Kafka 4.x runs only in KRaft mode, so teams without Kafka experience should plan time to learn that model before production. If your platform team already runs Kafka for other workloads, adding a telemetry topic is a small change. If not, the file-backed queue avoids a new stateful system to operate.

Network zone separation

When agents sit in application networks and the back end sits in a different zone, Kafka can act as a controlled crossing point with its own listeners, TLS and authentication. A local queue keeps data on the sending host and only needs the Collector's path to the back end. Check which zones your firewall rules allow to reach the Kafka brokers and whether the broker listeners will be encrypted and authenticated.

Kafka security overview

Failure isolation

A Kafka cluster adds a shared dependency. If it fails, every Collector that writes to it can be affected, and a bad topic configuration can slow all telemetry. A persistent queue on each Collector fails per host, so one node's problem stays local. Decide which failure is easier to contain in your environment, and test what happens to agents when the Kafka cluster is unreachable.

Operating cost

Kafka costs include broker compute, storage for retained telemetry, replication overhead, monitoring, and staff time for upgrades. The Apache Kafka project is Apache-2.0 licensed with no paid edition, so the cost is your infrastructure and people, not a license. A file_storage queue adds disk to existing Collector hosts. Ask for a sizing estimate based on your telemetry volume and retention before deciding, and see the sibling topic on preventing data loss for the file_storage option.

Kafka exporter and receiver settings that matter

The exporter runs on the agent or first-tier Collector and writes traces, metrics and logs to Kafka topics. The README marks it as beta for all three signals, so confirm the current status before you commit. Its producer is synchronous and does not batch, so the README recommends placing batch and queued retry processing in front of it. Without that pairing, each record travels on its own, which costs throughput and makes Kafka's behavior under load harder to predict.

  • Topic routing by signal: Set separate topics for traces, metrics and logs so retention, consumer groups and replay can differ per signal. Confirm the topic key names in the README.
  • Encoding: Choose the message encoding the receiving Collector can decode. Both sides must agree, so change it in one place only during a planned cutover.
  • Producer behavior: Review acknowledgement, timeout and compression settings against your broker's durability needs.
  • Batch processor: Place the batch processor before the exporter so records are grouped before they are produced.
  • Sending queue and retry: Enable queued retry so the Collector holds data while brokers are unavailable.

Confirm exact keys and defaults against the exporter README before you write the configuration, since beta components change between releases.

Configuration options and when each fits

This table compares the main design choices when Kafka sits between agent and gateway Collectors, with the conditions that favor each option and what to confirm before building. Read each row as a decision: find the question your team has already answered, then check the confirmation column before committing. The main takeaway is that encoding, topic layout and retention decisions are hard to reverse once consumers and downstream data depend on them.

OptionWhen it fitsWhat to confirm
Encoding (OTLP protobuf or JSON)OTLP protobuf suits high-volume pipelines where all consumers run the Collector and smaller payloads matter. JSON suits teams that need to inspect messages directly with standard Kafka tools.Confirm the encoding each Kafka exporter and receiver supports in the release you deploy, and that every consumer is configured with the same encoding.
Topic layout: one topic per signalSeparate topics for traces, metrics and logs let each signal have its own retention, partition count and consumer pool, and isolate a slow signal from the others.Confirm the topic names your exporter and receiver expect, and how many topics your Kafka cluster and access controls can manage.
Topic layout: combined topicA single topic suits small volumes and fewer operational objects, at the cost of coupling retention and throughput across signals.Confirm that consumers can filter by signal type and that one noisy signal will not starve the others of partitions.
Batch and queued retry processingNeeded with the Kafka exporter, whose README notes a synchronous producer that does not batch. Pair it with batch and queued retry processing in the agent or gateway.Confirm batch sizes and queue capacity against expected burst volume, and test how the sending queue behaves when the broker is unreachable.
Consumer group designOne consumer group per downstream gateway pool allows horizontal scaling. Separate groups let a second pipeline replay the same data for a different back end.Confirm offset commit behavior and how the group rebalances when Collectors restart or scale.
Partition countMore partitions allow more parallel consumers but add broker overhead. Choose a count that matches the planned consumer pool, since partitions are harder to change later.Confirm the partition key you need for ordering, and whether all spans of a trace must reach the same partition for later processing.
Retention periodLonger retention gives more room to absorb a back-end outage and replay data. Shorter retention limits disk use and exposure of telemetry that may contain sensitive attributes.Confirm the outage length you need to cover, the disk budget on brokers, and the data protection rules that apply to stored telemetry.
Persistent queue instead of KafkaA persistent queue with file storage can be enough for short outages on a single Collector. Choose it when no shared buffer is needed and operations should stay simpler.Confirm the outage length to cover and whether data must survive loss of the Collector host, since a local queue does not share data across Collectors.
Broker security and access controlNeeded whenever telemetry crosses a network boundary. Use TLS and SASL, and define ACLs so only the Collector identities can write and read the telemetry topics.Confirm the SASL mechanism your Kafka version supports, and that the authorization model denies topics without ACLs unless you deliberately allow otherwise.

How to set up Kafka between Collectors

This sequence builds a Kafka layer between agent and gateway Collectors so telemetry is queued during back-end outages and can be replayed afterward. Each step ends with a check that confirms the layer works before the next one starts.

  1. Size and deploy the Kafka cluster in KRaft mode

    The platform team sizes the brokers, storage and network for the expected telemetry volume and the retention window you need for replay, then deploys a KRaft cluster. Confirm the Kafka version against the downloads page and the upgrade notes before you choose it, because Kafka 4.0 and later support only KRaft and require Java 17 for brokers. Done means every broker reports healthy, the controllers form a quorum, and you can produce and consume a test message with the standard Kafka command-line tools from a host inside the network.

  2. Secure listeners and enable TLS and SASL

    Before any Collector connects, enable TLS on the client listeners and choose a SASL mechanism that your identity team can operate, such as SCRAM or OAUTHBEARER. Kafka security is optional, so an unsecured listener is the default unless you configure otherwise, and it must not be left open on a network that carries regulated data. Done means a client without valid credentials is refused and a client with them connects over an encrypted listener.

  3. Create topics and access control rules

    Create one topic per signal (traces, metrics and logs) with partition counts and retention settings that match your sizing work. Grant the agent Collectors write access only to their topics and the gateway Collectors read access under a separate consumer group. In KRaft clusters, resources without ACLs are restricted to super users unless allow.everyone.if.no.acl.found is set to true, so confirm that setting stays false. Done means a test producer can write to its topic, a consumer from another identity is denied, and the topic configuration matches your records.

  4. Configure the agent exporter with batching and queued retry

    On each agent Collector, configure the Kafka exporter with the topic, brokers, encoding and TLS and SASL settings. The exporter's README notes that its synchronous producer does not batch, so pair it with the batch processor and sending queue with retry, and check the component's stability level in its README before you rely on it in production. Done means the agent starts without errors, the Collector's internal metrics show exports succeeding, and test spans appear on the topic.

  5. Configure the gateway receiver and back-end exporter

    On the gateway Collectors, configure the Kafka receiver with the same topics, a consumer group, the matching encoding and the same authentication settings, then keep the existing back-end exporter in the pipeline. Confirm the receiver's README for the signals it supports and its stability level. Done means the gateway consumes the test records, the back end shows them arriving in the expected shape, and consumer lag stays near zero under normal load.

  6. Verify with test data and an induced back-end outage

    Send a known set of test telemetry through the agent, then block the path from the gateway to the back end for a set period while data continues to flow. Watch the Kafka consumer lag and the exporter's queue and refusal metrics during the outage, and confirm that the agents do not drop data they should have queued. Done means the records accumulated on the topics while the back end was down, and no test records were lost during the window.

  7. Replay queued data and confirm completeness

    Restore the back-end path and let the gateway consumers drain the backlog. Compare the record counts or test identifiers received by the back end with the set you sent, and check for duplicates, since at-least-once delivery can produce them. Done means every test record arrives once or is accounted for, consumer lag returns to normal, and the results are written down as the baseline for your runbook.

How batching and encodings change the data path

The Kafka exporter uses a synchronous producer that does not batch, so the Collector pipeline in front of it has to supply batching and retry behavior. The exporter README recommends pairing it with the batch processor and the exporter's queued retry, both of which sit in the agent Collector before data reaches Kafka. Without them, each small payload becomes its own produce request, which raises broker load and makes throughput depend on how fast individual requests return. Plan the batch processor's size and timeout settings and the sending queue capacity together, because the queue is what absorbs a broker slowdown while the agent keeps accepting data. Check the README for the chosen Collector version before you copy any values, since the exporter's options and defaults change between releases.

The encoding you choose decides what each gateway Collector must parse after it reads from the topic. The Kafka exporter and receiver expose an encoding setting, and the two sides must agree on it exactly, including the signal type and any batching format. A mismatch will not fail quietly in a way that is easy to spot: a gateway can start and consume messages while producing empty or malformed output. Treat the encoding as a versioned interface between teams. Record it in the configuration of both tiers, test a round trip with one signal type before enabling all three, and confirm which encodings each receiver version supports. Because both components are beta for the signals they cover, expect configuration keys to change and pin versions deliberately.

Message size is the constraint that links batch size to the broker. A batch processor that groups many records into one message can produce a payload larger than the broker or topic will accept, and the produce request then fails and the data falls back to retries. Confirm the maximum message size on the brokers and on the topic, then set the batch size on the agent so that typical bursts stay well below that limit with margin for encoding overhead. The broker-side settings belong to your Kafka deployment, so confirm their names and defaults in the documentation for the Kafka release you run, such as the Apache Kafka 4.3 upgrade notes, and in your own cluster configuration. Test with a realistic burst of your own telemetry, because the size of a batch depends on your attribute volume and not on any generic figure.

Securing the Kafka path between Collectors

Kafka sits in the middle of your telemetry path, so it needs the same controls as the Collectors on either side of it. The cards below cover transport and client authentication, broker access control, Collector credentials and configuration, data minimization before records reach the topic, and network exposure of Collector endpoints.

Choose TLS and SASL mechanisms

Kafka encrypts client traffic with SSL/TLS and authenticates clients with SASL, using GSSAPI (Kerberos), PLAIN, SCRAM-SHA-256, SCRAM-SHA-512 or OAUTHBEARER. Security is optional in Kafka, so a cluster can run with unsecured or mixed listeners. Confirm that every agent and gateway Collector connects to a secured listener, and pick the mechanism that matches your identity provider. Check the exact client settings in the Kafka exporter and receiver READMEs before you deploy.

Kafka security overview

Enforce ACLs in the metadata log

In KRaft clusters, the StandardAuthorizer stores ACLs in the cluster metadata log. Resources without ACLs are restricted to super users unless allow.everyone.if.no.acl.found is set to true. Create explicit ACLs for the exporter principal (write to telemetry topics) and the receiver principal (read from them and the consumer group). Keep the super-user list short, and confirm that the default behavior blocks clients you have not yet granted access to.

Kafka authorization docs

Use authenticator extensions for Collectors

Collector authenticator extensions handle credentials on both sides of the buffer. On the receiving side, an extension such as OIDC can authenticate incoming connections. On the sending side, the oauth2client extension can add credentials to outgoing exporter requests. Store the Collector configuration in a protected location, encrypt it where possible, and keep client secrets out of files that are readable by other users. Rotate the credentials that the Collectors use to reach Kafka.

Collector configuration docs

Redact before data enters Kafka

A topic holds copies of telemetry for as long as retention allows, and every consumer that reads it sees the same data. Apply the redaction processor on the agent Collector, before the Kafka exporter, so that sensitive attributes such as tokens, personal identifiers and query parameters never reach a broker. Review which attributes your applications emit, because redaction rules are only as complete as the attribute list you write. Document this step as part of your data handling controls.

Collector security practices

Keep Collector endpoints off public interfaces

Since Collector v0.110.0, server components bind to localhost by default rather than 0.0.0.0. Any receiver or extension you change to listen on a wider address becomes reachable by whatever network can route to it. Set explicit bind addresses for the receivers that accept application traffic, restrict them with network policy or firewall rules, and confirm the bound addresses with a port scan after each change. Build only the components you need, so unused endpoints do not exist in the binary.

Operating the buffer after go-live

The buffer is only useful if someone watches it, so the first operating decision is which signals page a human. On the Collector side, watch the sending queue on each agent and gateway, along with refused or failed export counts, since a growing queue means Kafka or the back end is slower than the data arriving. On the Kafka side, track consumer lag for the consumer group that feeds the gateway Collectors. Lag that rises during a back-end outage is expected and should drain after recovery. Lag that keeps climbing after the back end is healthy means the consumers cannot keep up, and that needs a separate response. Confirm the exact metric names with the Collector version you deploy and with your Kafka monitoring stack, because they change between releases.

Capacity planning for an outage comes down to arithmetic you should do with your own numbers: the sustained telemetry rate, the longest outage you intend to absorb, and the disk the brokers can spend on retention once replication is counted. Topic retention and the replication factor set how much data survives an outage, so agree that figure with the owners of the back end before go-live. Also confirm what happens when retention is exhausted, because data that ages out before replay is lost without warning. Kafka's own sizing guidance and your broker hardware will decide the rest, and DeployOpen typically builds this calculation into the written scope.

Kafka is a separate system with its own patch cycle, so it needs its own runbook. Plan upgrades against the supported releases on the Apache Kafka downloads page and the time-based release plan, and read the upgrade notes for every hop, since Kafka 4.0 removed ZooKeeper mode and requires KRaft. Back up cluster configuration and ACLs, and test that a broker restart does not interrupt Collector exporting. Replay needs a runbook too: record which consumer group offsets to reset, how to avoid duplicate writes at the back end, and who approves the replay rate so it does not overload the recovering system. Rehearse this procedure in a non-production environment before you depend on it during an incident.

Questions teams ask before using Kafka between Collectors

Is a persistent queue in the Collector enough instead of Kafka?

Often, yes, for short back-end outages on a single gateway or a small number of Collectors. A persistent sending queue backed by the file_storage extension keeps data on local disk while the back end is unavailable, and it needs no extra cluster to run. Kafka earns its place when the buffer must outlive a single Collector host, when several independent consumers need the same telemetry, or when outages last long enough that local disk becomes the limit. Measure your outage length, data rate and retention needs before choosing. The sibling guide on preventing data loss covers how to size the queue first.

What drives the cost of running Kafka between Collectors?

The main cost is the Kafka cluster itself: brokers, storage sized for your retention window, replication, and the network between agents, brokers and gateways. Kafka is licensed under Apache-2.0 with no paid edition from the project, so software licensing is not the cost driver. Labor is the larger variable: someone must operate brokers, monitor lag and handle upgrades. Costs rise with higher telemetry volume, longer retention, more replicas, cross-zone traffic and TLS and ACL work. Ask any partner for a quote that itemizes cluster sizing, security configuration, testing and ongoing support separately.

How long does a Kafka buffer project take?

Duration depends on the scope agreed in writing, not on a fixed template. The main drivers are whether you already run a Kafka cluster, how many Collector pipelines need changes, how much security work is required (TLS, SASL mechanisms, ACLs), how much testing you need to prove replay and outage behavior, and how quickly your network and identity teams can provision access. If you already operate Kafka, the work is mostly Collector configuration and testing. If you do not, the cluster build and its security review will dominate the timeline. Ask for a schedule tied to milestones.

What does the team need to provide for a Kafka buffer engagement?

Expect to provide access and decisions rather than code. Typically this includes the Collector deployment topology (agents, gateways and where each runs), the back ends that must receive data, the network paths and firewall changes, identity sources for SASL or OAuth, a named owner for topic and ACL decisions, and a test window where outages can be simulated. You will also need to confirm retention, partition and encoding requirements with your data owners. Any partner should list these inputs in the written scope so gaps show up before the build starts.

Can our own platform team build a Kafka buffer without outside help?

A team that already runs Kafka and operates OpenTelemetry Collectors can build this in-house, provided it has clear ownership and time for testing. The Kafka exporter and receiver are beta for traces, metrics and logs, and the exporter does not batch on its own, so the team must pair it with batch and queued retry processing and verify the behavior under load. Teams without Kafka experience usually need to learn broker operations, KRaft cluster management, upgrades and ACL design before they can run the buffer safely. Weigh those skills against your delivery deadline.

What do the TLS, SASL and ACL settings involve?

Kafka supports SSL/TLS for encryption and SASL for authentication, with GSSAPI (Kerberos), PLAIN, SCRAM-SHA-256, SCRAM-SHA-512 and OAUTHBEARER as documented mechanisms. Security is optional in Kafka, so you must enable it deliberately and avoid leaving unsecured listeners in production. In KRaft clusters, the StandardAuthorizer stores ACLs in the metadata log, and resources without ACLs are restricted to super users unless allow.everyone.if.no.acl.found is set to true. Plan certificate issuance, rotation, credential storage on Collector hosts and per-pipeline ACLs as separate work items. Confirm each choice against your identity and key management standards.

Which Kafka version should we run for a new buffer?

Choose a release from the supported list on the Apache Kafka downloads page and confirm it against your own support policy. Kafka 4.0 and later support only KRaft mode, so ZooKeeper-based clusters must migrate first, and KRaft clusters older than 3.3.x should move to 3.9.x before 4.x. Brokers and tools require Java 17 from Kafka 4.0 onward, while clients need at least Java 11. Rolling upgrades are supported from releases within the past year to the latest version. Confirm the Collector exporter and receiver versions you use also support your chosen Kafka client settings.

How DeployOpen scopes and delivers Kafka buffering for Collectors

DeployOpen plans, builds and hands over Kafka buffering between agent and gateway Collectors inside your own infrastructure. Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts, so your team knows what Kafka, Collector and replay behavior it will own.

How we scope

  • We confirm which signals (traces, metrics, logs) would pass through Kafka and which can go directly to the back end.
  • We agree the Kafka cluster target, Collector versions, encodings and topic layout in the written scope.
  • We record the back-end outage and replay requirements that decide whether Kafka is needed at all.

How we build

  • We configure the Kafka exporter on agent Collectors and the Kafka receiver on gateway Collectors, paired with batch and queued retry processing.
  • We set topic partitioning, message encoding and batch sizes, then test them against your expected telemetry volume.
  • We test back-end outage and replay scenarios, checking for dropped data, duplicate delivery and consumer lag.

How we hand over

  • We deliver the Collector configuration, Kafka topic and ACL settings, and security settings for review by your team.
  • We document the replay procedure, the signals to monitor and the steps for resizing topics or Collectors.
  • We walk your platform and security engineers through the build and the known limits of the beta components.

How we support

  • Ongoing support, upgrades and continuous testing are available as retainers after handover.
  • Retainers can cover Kafka version upgrades, Collector release updates and retesting of replay behavior.
  • We rerun outage and replay tests after significant topology or volume changes that your team requests.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.