Preventing data loss in the OpenTelemetry Collector

Where telemetry is lost in a Collector pipeline, how sending queues, retries and a file_storage write-ahead log close those gaps, and when Kafka is worth its operating cost.

On this page

Preventing data loss in the OpenTelemetry Collector starts with knowing where data sits

A back-end outage, a Collector restart or a sudden burst of telemetry can drop data inside the Collector, and the fix is a combination of sending queues, retries, persistent storage and, for some estates, Kafka between Collectors and the back end. Start by mapping where each signal can be lost before you tune anything. The OpenTelemetry Collector receives, processes and exports telemetry, so loss can happen at the receiver when a client is refused, in memory queues that hold batches waiting for export, or on disk if you have configured persistence. OpenTelemetry itself is vendor-agnostic, and the Collector repository is licensed under Apache-2.0, so the pipeline design is yours to own rather than dictated by a single back-end product.

Each of those loss points needs a different control. Memory queues are fast but empty on a crash or restart, so anything still in them when the process stops is gone. Persistence moves that waiting data to disk, and the file storage extension is the component that does this: it persists state to a local directory that must already exist and requires read and write access for the Collector process. Confirm that the directory is created by your provisioning, has the right ownership on each node, and sits on storage that survives the pod or VM lifecycle you run. The sections that follow cover sizing queues and retries, configuring the write-ahead log, and deciding when Kafka belongs in the design.

Where telemetry is lost and which control covers each gap

When the back end refuses connections or times out for a short period, the exporter's retry behavior and sending queue absorb the failure. Batches that fail are held in the Collector's memory and retried, while new telemetry keeps arriving and waits in the same queue. For a brief outage, this is usually enough, provided the queue has room for the data that accumulates.

  • Failed batches stay in memory: retries run against batches held in process memory, so they are lost if the Collector stops before the back end recovers.
  • New data queues behind retries: while retries run, incoming telemetry occupies the sending queue, and queue capacity becomes the limit on how long an outage the Collector can absorb.
  • Backpressure reaches the senders: when the queue is full, the Collector refuses data, and the sending application or agent decides whether to retry or drop it.
  • The memory limiter protects the process: the memory_limiter processor refuses data before the process exhausts its memory, which keeps the Collector alive but still loses the refused data.
  • Retry settings define the window: the length of a survivable outage depends on the retry and queue settings in your Collector version's exporter documentation, so confirm those values rather than assuming them.

Check the retry and queue settings in the exporter README for your Collector version, then test a short back-end outage under realistic load and confirm the refused and dropped counts.

How sending queues and retries decide what survives a back-end outage

When a back end becomes unavailable, the Collector decides what survives by how much telemetry it can hold while exports fail. The sending queue is an in-memory buffer that sits between the processors and each exporter. Batches wait there while the exporter retries failed requests, and once the queue is full, new data is refused or dropped depending on the configuration. Retries are the re-attempts the exporter makes for failed sends. They buy time for a short back-end blip, but they do not add storage. A long outage fills the queue, and whatever is in memory is lost if the Collector process restarts.

Queue capacity is a direct trade-off against memory. Every queued batch occupies heap memory, so a larger queue holds more data through a longer outage but raises the risk that the Collector is killed by its container memory limit before the back end recovers. Size the queue as a share of the memory the container can actually use after the memory_limiter processor and the Collector's own overhead are accounted for, not as an independent number. A queue that can hold more than the container allows is a configuration error that appears only during an incident.

Confirm the current option names, their defaults and units against the exporter helper documentation for the exact Collector version you pin, since those settings change between releases and the facts available here do not include them. Then test the setting under load: stop the back end in a non-production environment, watch the queue and refused-data signals, and record how long the queue fills at your real ingest rate. That measurement, not a default, tells you whether memory alone is enough or whether the persistent storage option is needed for the outage durations you must cover.

How data moves through receivers, queues, file storage and the back end

Telemetry starts at the application, enters the Collector through a receiver, and passes through the processor chain before reaching the sending queue. The in-memory queue is fast but lost if the process crashes, while a persistent queue backed by file_storage writes to a local directory that must already exist and be writable. Check what happens when the queue fills, which records are dropped, and whether the exporter retries before the back end accepts the data.

Two queue paths: in-memory loses data on crash, persistent queue survives restarts.

How to add a persistent write-ahead log with file_storage

This sequence gives the Collector a disk-backed sending queue so telemetry queued during a back-end outage survives both the outage and a Collector restart. Each step ends with a check that confirms the storage path, the queue and the recovery behavior before the setup is trusted.

  1. Create and permission the storage directory

    The platform engineer creates a dedicated directory on a local disk that the Collector process can write to, such as a path reserved for Collector state, and sets ownership to the user the Collector runs as. The file_storage extension requires that the directory already exists and that the Collector has both read and write access, so the Collector will not create it for you. Confirm the result by running a write test as the Collector user, for example by creating and deleting a temporary file in that directory, and by checking that the directory is not shared with unrelated services.

  2. Declare the file_storage extension

    The engineer adds a file_storage entry under the extensions section of the Collector configuration and sets its directory to the path created in the previous step. Keep the extension name consistent across the file, since the exporter will reference it by that name. Validate the configuration file before deploying it, using the Collector's validate command in a non-production environment, and confirm that the extension appears in the startup log without errors about the path or permissions.

  3. Reference the extension from the exporter queue

    In the exporter block, the engineer sets the sending_queue to use the file_storage extension as its storage backend and confirms that queue size and retry settings are present and sized for the expected backlog. The exporter must also be listed in the pipeline it serves. Review the change in version control so the reviewer can see which exporter is persistent and which extension it depends on. The step is complete when the configuration validates and the exporter shows the storage reference in the rendered config.

  4. Restart the Collector and verify startup

    The operator restarts the Collector in a test environment with the new configuration and reviews the startup logs for the extension and exporter initialization. Check that the process starts without permission errors, that the directory now holds files created by the Collector, and that the Collector's own internal telemetry reports the exporter as running. If startup fails on a permission error, correct ownership on the directory rather than running the process as a broader user.

  5. Force a back-end outage in a test environment

    In a test environment that mirrors production pipelines, the engineer makes the back end unreachable, for example by stopping its receiving endpoint or blocking the exporter's network path, and sends a known volume of test telemetry through the pipeline. Watch the queue size and exporter failure metrics on the Collector's internal telemetry to confirm that data is accumulating on disk. The step is complete when the queue grows during the outage and the exporter reports failed send attempts instead of silently dropping data.

  6. Confirm data resumes after recovery

    The engineer restores the back end and watches the queue drain and the exporter report successful sends. The test should count the records that were sent during the test window and compare them with the records generated, so that the team knows how many items were replayed and whether any were lost. Record the result, including any mismatch, as the evidence for this environment. Reproduce the test with the same volume before relying on the configuration in production.

  7. Confirm a restart keeps queued items

    With the back end still unavailable, the engineer fills the queue with test telemetry and restarts the Collector process. After the restart, the engineer checks that the queue size reported on startup matches the backlog before the restart, and that the files in the storage directory are still present. When the back end is restored, the same records should drain from the queue. The step closes when the team has a documented comparison of queued and delivered counts across the restart, which is the evidence needed to call the queue persistent.

When Kafka should sit between Collectors and the back end

A persistent queue on each Collector covers short back-end outages on the same host. Kafka becomes worth considering when the buffer must outlast local disk, feed more than one consumer, or fit a platform your organization already runs. Each card below is a decision point to check against your own traffic and failure history.

Outage longer than local disk

A file-backed queue holds data only as long as the Collector host has free disk. Estimate how long your back end could be unavailable, then multiply that by your peak telemetry rate in bytes to see whether local storage covers it. If the answer is no, Kafka's retention on a separate cluster can hold the data for the full outage. Ask your back-end team for their longest recent incident window before sizing anything.

Replay to a second consumer

If the same telemetry must also reach a data lake, a SIEM or a second back end, a Kafka topic lets each consumer read at its own pace from the same stream. A Collector queue is drained by one exporter path and is gone once sent. Confirm which consumers need the data and whether they need it in the same encoding.

Multi-team fan-out

When several platform, security and application teams each want telemetry routed under their own rules, a shared topic separates producers from consumers. Teams can add consumers without changing the Collector configuration that feeds the topic. The trade-off is that topic naming, access control and retention become shared responsibilities that need an owner.

Existing Kafka platform

If your organization already runs and supports Kafka, adding a telemetry topic may cost less than operating a new buffering tier. Check whether the platform team has capacity for another producer, whether the clusters are sized for telemetry volume, and whether access controls can separate telemetry topics from business data. See the Apache Kafka topic plan for how the Collector side is wired.

Operating cost of Kafka

Kafka adds brokers, storage, monitoring, upgrades and a team that understands partitions and retention. These costs recur for as long as the pipeline runs, and they grow with telemetry volume. Ask any partner for a quote that separates one-time build work from ongoing operation, and compare it with the cost of a larger persistent queue and longer host disks.

When a persistent queue is enough

If outages are short, there is one consumer, and the Collector hosts have room for a file-backed queue, adding Kafka usually increases failure points without a clear gain. A persistent queue with the file_storage extension keeps data across Collector restarts on the same host. Test the queue by stopping the back end during a load test and checking what is lost before deciding on Kafka.

File storage README

Resilience options and when each fits

This table compares four ways to keep telemetry from being lost when a back end slows or fails: an in-memory sending queue, a sending queue backed by file_storage, retries with backoff, and Kafka between agent and gateway Collectors. Read each row for what it protects against and what it costs in operations, then combine layers where the failure modes you care about call for more than one.

OptionProtects againstMain trade-offWhen it fits
In-memory sending queue onlyShort back-end slowdowns and brief export errors while the Collector process keeps runningQueued data is lost if the Collector restarts, is evicted or crashes before exportLower-stakes telemetry where a brief gap is acceptable and restarts are rare
Sending queue with file_storageData already queued surviving a Collector restart, as long as the storage directory persistsNeeds a writable local directory with the right permissions and disk capacity planned, plus slower throughput to confirm under loadAgents or gateways where restarts or node replacements are routine and queued data must not vanish
Retries with backoffTransient export failures such as brief network faults or back-end throttlingRetries extend how long data sits in memory or on disk, so queue capacity must cover the retry windowNearly every pipeline, as a baseline, paired with a queue rather than on its own
Kafka between agent and gateway CollectorsExtended back-end outages, with data replayed from retained topics after recoveryAdds a Kafka cluster to build, secure, size and operate, plus encoding and retention decisionsLarge fleets or regulated environments where a durable, replayable buffer outweighs the added platform work
Layered: file_storage queue, retries and KafkaRestarts, transient errors and long outages togetherHighest operational surface and the most components to monitor and testTelemetry that feeds incident response or compliance evidence and must survive several failure types

Security and operational risks of persistent buffering

A persistent queue keeps telemetry on the Collector host long after it would otherwise have left memory, which changes who can read it and what happens when it fills. The cards below cover the controls to set before the write-ahead log goes live and the signals that show whether it is working.

Encrypt and restrict buffered data at rest

Anything the sending queue writes to disk is telemetry at rest, and it may contain user identifiers, tokens or request payloads that were never meant to be stored. Confirm that the volume holding the file_storage directory is encrypted, and that backups, snapshots and container image layers do not capture it unexpectedly. Ask your security team to classify the buffer the same way as the log store it feeds.

Set the storage directory permissions

The file storage extension needs a local directory that already exists and that the Collector process can read and write. Make the directory owned by the service account that runs the Collector, with no group or world access, and confirm this after every deployment or image rebuild. Other processes on the host should not be able to read queued data or replace the files.

File storage README

Redact before data reaches disk

Order matters: the redaction processor must run before the batch and queue stages, so sensitive attributes are removed before they are ever written to the write-ahead log. Scrubbing only at the back end leaves copies on every gateway disk in the meantime. Test the processor against sample payloads that include real-looking secrets, and review what attributes your SDKs add by default.

Store configuration and authenticate endpoints

Collector configuration often contains exporter endpoints and credentials, so keep it in a secrets store and inject values at runtime rather than committing them to source control. Require authentication on receivers that accept data from other networks, using an authenticator extension, and add credentials to exporter requests the same way. Follow the security best practices for encryption and authentication before you enable persistence.

Collector security practices

Monitor queue fill and dropped data

A persistent queue hides backlog from the application, so the failure mode becomes a slowly growing disk and then refused or dropped data. Alert on the queue's fill level and on exporter failures and refused-data counts, and set the disk alert well below the point where the volume fills. Rehearse a back-end outage in a test environment to confirm the alerts fire before data is lost.

Questions teams ask before they size queues or add Kafka

What drives the cost and effort of preventing data loss in the Collector?

The biggest drivers are how many pipelines and signals need protection, how long a back-end outage must be survived, and how much telemetry arrives at peak. Each added pipeline, retention target and failure mode adds configuration, testing and operating work. Costs fall into one-time design and build work, then recurring tuning, upgrades and retesting as volumes change. Ask any partner for a quote that lists the pipelines in scope, the outage duration you must survive, the storage and Kafka components included, and whether testing and handover are priced separately.

How long does a typical implementation take?

It depends on scope and environment: the number of Collectors and pipelines, whether a persistent queue or Kafka is added, how many back ends must be covered, and how much of the host and network setup already exists. Teams with existing Collector configuration and a clear outage target usually move faster than teams that must first agree on retention and ownership. Ask for a timeline tied to a written scope, with separate milestones for sizing, the build, outage testing and handover.

What must our team provide before the work starts?

Expect to provide back-end details: the endpoint type, its ingestion limits, its authentication model and its documented behavior during slowdowns. You also need the storage plan for the persistent queue, including a local directory that already exists on each Collector host with read and write access for the Collector process. A test window is essential, because outage tests interrupt a back end and need agreed hours, a rollback plan and someone who can confirm data arrived afterward.

Can our own team do this without a partner?

Yes, if you have engineers who know the Collector configuration model, can read component stability notes and can run controlled failure tests. The file storage extension and retry settings are small in configuration, but sizing them correctly requires measured telemetry rates and back-end behavior. Teams often underestimate the test and monitoring work, especially checking refused-data and queue signals under load. A partner can supply a second set of eyes on the design or take the full build, depending on your capacity.

How do we size the sending queue and retry settings?

Start from the telemetry rate at peak, the outage length you must absorb and the memory or disk you can give each Collector. The sending queue must hold roughly the data produced during that outage, while retries must back off long enough not to overload a recovering back end. Set limits, then measure queue usage and refused data during a simulated slowdown. Adjust until the queue drains after recovery without memory pressure. Record the chosen numbers so they can be reviewed when volumes grow.

When is Kafka worth adding between Collectors and the back end?

Kafka is worth considering when outages must be survived across many hosts, when several consumers need the same telemetry, or when a persistent queue on each Collector cannot hold enough data or cannot be replayed centrally. It adds components to run, including brokers, retention, access control and monitoring, so it is a platform commitment. If a local persistent queue meets the outage target, Kafka may add more operating cost than it removes. Ask whether your Kafka team can run the cluster, and see the OpenTelemetry Collector documentation for current pipeline options.

How do we test that data survives a back-end outage?

Run a controlled test in which the back end is stopped or throttled for a defined period while known telemetry is sent. Record the count of spans, metrics and log records at the source, then compare it with what the back end stores after recovery. Watch queue size, retry counts and refused-data signals during the outage, and confirm the Collector restarts cleanly with the persistent queue intact. Repeat the test after configuration changes and after Collector upgrades, and keep the results as evidence for operations and audit reviews.

How DeployOpen scopes and delivers Collector resilience work

DeployOpen approaches preventing data loss in the OpenTelemetry Collector as a written, fixed-scope piece of platform work inside your own infrastructure. We agree which pipelines, back ends and failure cases are covered, build and test the queue and storage settings against them, and document the result so your team can run it.

How we scope

  • We map every pipeline, receiver, exporter and back end that must keep data through an outage.
  • We agree in writing which failure modes are in scope, such as back-end unavailability, Collector restarts and node loss.
  • We record the sizing inputs we need from you, including expected telemetry volume and acceptable loss per signal.

How we build

  • We configure sending queues, retry behavior and memory limits, then test them against simulated back-end outages.
  • We add a persistent write-ahead log with the file_storage extension on directories your team provisions and secures.
  • We evaluate whether Kafka should sit between Collectors and the back end, and build it only if the written scope requires it.

How we hand over

  • We deliver the configuration in version control, with the test results that show what survives each outage scenario.
  • We document queue capacity signals, refused-data metrics and the alerts your operators should watch.
  • We walk your platform and operations teams through restart, replay and recovery steps before the engagement closes.

How we support

  • Ongoing support, Collector upgrades and continuous testing are available as retainers after the initial scope closes.
  • Retainer work can cover re-testing queue and storage settings when Collector versions or back-end capacity change.
  • Support scope, response expectations and fees are confirmed in the written agreement before any retainer work starts.

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.