Troubleshoot Missing Log Bytes

Overview

The Datadog Agent collects application logs and sends them to Datadog. For applications that write logs to files, the Agent reads those files as new entries are added. Applications often rotate their log files, replacing the active file with a new one when it reaches a size or age limit.

If the Agent stops reading a rotated file before reaching the end, the remaining data is not sent to Datadog. The Agent reports this as missing log bytes. You may notice gaps in Log Explorer or see a warning in the Agent log file:

WARN | After rotation close timeout (60s), there were 148213 bytes remaining unread for file "/var/log/app/app.log". These unread logs are now lost. Consider increasing DD_LOGS_CONFIG_CLOSE_TIMEOUT

The Agent continues reading a rotated file for logs_config.close_timeout (60 seconds by default) after detecting rotation. If unread data remains when this timeout expires, the Agent closes the file and writes the warning above.

Possible causes

Backpressure occurs when a stage in the Agent’s logs pipeline cannot keep up, slowing earlier stages and file reads. Frequent rotation or high log volume can also prevent the Agent from finishing within the timeout.

  • The Agent cannot deliver payloads to the Datadog intake because of network, proxy, authentication, or intake errors.
  • Network or intake latency slows successful log submissions.
  • Encoding, batching, or compression is limiting a logs pipeline.
  • Processing rules or multi-line processing are limiting a logs pipeline.
  • The log rate exceeds the CPU or network capacity available to the Agent.
  • The affected file rotates before the Agent can read the data written during the rotation interval, even when the downstream pipeline is not saturated.

Diagnose missing log bytes

  1. Search the Agent log file for the rotation warning. Record the affected file paths, timestamps, and number of unread bytes.
  2. If you use Agent 7.82.0 or later, run the status command and read the Interpret Logs Agent Backpressure section. Compare the retained history with the warning timestamps.
  3. If several rows in the Logs Agent Backpressure table are saturated, investigate them in this order: destination_reliable_N, worker, strategy, and processor. Use the Choose a tuning action section to select the next step for the first saturated component in that list.
  4. Apply one relevant change, then follow the Verify the result section under representative log volume before addressing another component.
  5. If the Agent remains unable to process the required volume, follow the Reduce log volume section.

To detect missing log bytes without searching the Agent log file, use the datadog.agent.logs.bytes_missed metric. This metric counts the bytes that the Agent did not read from rotated files before closing them. Create a metric monitor on this metric to receive an alert when the Agent loses log data.

Interpret Logs Agent Backpressure

Agent versions 7.82.0 and later include a Logs Agent Backpressure section in the status command. The section reports recent utilization for the processor, batching strategy, sender workers, and destinations. It retains peak utilization for approximately 10 hours and detailed saturation duration for 30 minutes.

sudo datadog-agent status

You can also find the section in status.log inside an Agent flare. Because the history resets when the Agent restarts, take a flare before restarting.

Logs Agent Backpressure
=======================

  Overall state: SATURATED
  Reason: destination_reliable_0 pipeline q0s0 is currently saturated (saturated for 3m20s in the last 30m)

  Component              Instance Current   5m avg/max    30m avg/max    2h max    5h max    10h max    30m saturated    Last saturated
  processor              0        20%       18/26%        15/41%         55%       55%       55%        0s               -
  strategy               0        14%       12/19%        13/22%         22%       22%       22%        0s               -
  worker                 q0s0     46%       43/63%        27/63%         63%       63%       63%        0s               -
  destination_reliable_0 q0s0     93%       82/93%        71/93%         93%       93%       93%        3m20s            12:09:42

Because destination_reliable_0 is saturated, follow the Resolve delivery errors section before changing processor or batching settings.

Overall state

StateMeaning
HEALTHYNo component is saturated and none was saturated in the last 30 minutes.
WARNINGNo component is saturated, but at least one was saturated in the last 30 minutes. Compare Last saturated with the missing-bytes warning timestamps.
SATURATEDAt least one component reached the saturation threshold within the current 15-second window.

Saturation means that a component spent at least 90% of its sampled time working instead of waiting. Use the rotation warning to confirm loss and the table to identify a possible constraint.

Table columns

ColumnMeaning
ComponentThe logs pipeline stage. See the Choose a tuning action section.
InstanceThe pipeline or destination instance.
CurrentUtilization smoothed over approximately 15 seconds.
5m avg/max and 30m avg/maxAverage and peak utilization during the stated window.
2h max, 5h max, and 10h maxPeak utilization during the stated window.
30m saturatedTime spent at or above 90% utilization during the last 30 minutes.
Last saturatedTime of the latest retained saturation sample. A - means that no retained sample is available.

Give the Agent more time to read rotated files

Increase logs_config.close_timeout when the Agent needs more than the default 60 seconds to finish reading a rotated file. To use a 180-second timeout:

datadog.yaml

logs_config:
  close_timeout: 180
DD_LOGS_CONFIG_CLOSE_TIMEOUT=180

After changing the timeout, search the Agent log file for new rotation warnings during representative log volume. If warnings continue, increase the timeout again or use the Choose a tuning action section to select an action for the saturated component. Longer timeouts keep rotated files open and can increase file descriptor and disk usage.

If the Agent does not tail all matching files, check logs_config.open_files_limit instead. For configuration details, see Increase the Number of Log Files Tailed by the Agent.

Tune the Agent

Choose a tuning action

ComponentInterpretationStart with this section
destination_reliable_NLog submissions are delayed or retried.Resolve delivery errors
workerPayloads are waiting to be sent.Resolve delivery errors
strategyEncoding, batching, or compression work is at capacity.Disable compression or increase pipeline parallelism
processorLog processing is at capacity.Reduce log processing or increase pipeline parallelism

Resolve delivery errors

If destination_reliable_N is saturated, open the Agent log file and inspect entries near the missing-byte warning timestamp for failed or retried submissions. Resolve authentication, rejection, proxy, DNS, and connection errors. Verify the proxy configuration, network access to Datadog endpoints, and Datadog site.

Disable compression

For HTTPS delivery, compression is enabled by default. If strategy is saturated and the Agent’s CPU usage is high, consider disabling compression. This reduces compression work, but increases payload size and the number of bytes sent to the logs intake:

datadog.yaml

logs_config:
  use_compression: false

After the change, run the status command and confirm that strategy spends less time saturated. Re-enable compression if network use reaches capacity or the Agent log file shows new delivery errors.

Increase pipeline parallelism

By default, the Agent runs one logs pipeline per available logical CPU, up to four pipelines.

If processor or strategy is saturated and the host CPU is below capacity, increase logs_config.pipelines. For example, on a host with eight logical CPUs available to the Agent:

datadog.yaml

logs_config:
  pipelines: 8

Additional pipelines help when the Agent collects from multiple log sources. A single source remains on one pipeline. More pipelines can increase Agent CPU, memory, and total HTTP send concurrency. After the change, run the status command and confirm that the targeted component spends less time saturated.

Reduce log processing

If processor is saturated, review the configured processing rules. Global rules run against every log collected by the Agent. When a rule applies to one source, move it to that source’s integration configuration:

conf.d/myapp.d/conf.yaml

logs:
  - type: file
    path: /var/log/app/app.log
    service: myapp
    source: myapp
    log_processing_rules:
      - type: exclude_at_match
        name: exclude_debug
        pattern: \[DEBUG\]

Remove duplicate rules from global logs_config.processing_rules and source-level log_processing_rules. Starting with Agent 7.82.0, automatic multi-line detection is enabled by default. If the processor component is saturated and your logs do not require multi-line aggregation, consider disabling it:

datadog.yaml

logs_config:
  auto_multi_line_detection: false

If a source has a known multi-line format, configure a source-level multi_line processing rule instead of using automatic detection. After the change, run the status command to compare processor saturation and verify in Log Explorer that related lines remain grouped correctly.

Reduce log volume

If the Agent cannot process the required volume within the available host and network capacity, filter logs that you do not need. An exclude_at_match processing rule drops matching logs before they leave the host:

datadog.yaml

logs_config:
  processing_rules:
    - type: exclude_at_match
      name: exclude_health_checks
      pattern: GET /health

Use a source-level log_processing_rules entry instead when the filter applies to only one log source.

Verify the result

Test each change under representative log volume:

  1. Run the status command:
    sudo datadog-agent status
  2. Confirm that the targeted component spends less time at or above 90% utilization. The overall state remains WARNING for up to 30 minutes after saturation clears.
  3. Search the Agent log file for new remaining unread warnings.

If a change does not reduce saturation or the frequency of new rotation warnings, revert it. Then select the next action from the Choose a tuning action section. If saturation moves to a different component, use the action listed for that component.

Contact Datadog Support

If the steps on this page do not resolve the issue, contact Datadog Support. Submit a flare while the pipeline is saturated and before restarting the Agent.

Further reading