OTAGENT-286 Add support for filelog receiver #1725
Open
+138
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
To collect logs in Kubernetes environments, the
filelog
receiver requires specific volumes to be mounted to theotel-agent
container:/var/log/pods
/var/log/containers
/var/lib/docker/containers
Currently, the Helm chart does not provide a way to mount these additional volumes for the
otel-agent
container.Proposed Solution
Introduce new Helm chart parameters to enable filelog receiver support and allow mounting additional volumes in the
otel-agent
container:datadog.otelCollector.logs.enabled
:When set to
true
, the Helm chart will check the OTel Collector configuration for afilelog
receiver definition. If the receiver is defined, it mounts the required volumes to collect logs from containers and pods.agents.containers.otelAgent.volumeMounts
:Specify additional volume mounts in the
otel-agent
container.Example configuration:
This implementation maintains backward compatibility by requiring explicit configuration changes to enable the new behavior.
Comparison with the OpenTelemetry Helm Chart and Operator
The OpenTelemetry Collector Helm Chart allows customers to configure the
filelog
receiver in two ways:Logs Collection Preset
When enabled, the chart adds a
filelogreceiver
to the logs pipeline. This receiver is configured to read the files where the Kubernetes container runtime writes all containers' console output (e.g./var/log/pods/*/*/*.log
).Reference Links:
Manual Configuration
Customers can also manually add additional volumes and mounts using
extraVolumes
andextraVolumeMounts
. Note that this behavior is not documented in the Helm chart docs or the GitHub README.Reference Link:
Proposed Solution Parallels
Our new parameter
datadog.otelCollector.logs.enabled
offers a developer experience similar to the Logs Collection Preset (presets.logsCollection.enabled
) in the OpenTelemetry Collector Helm Chart. This approach should be intuitive for customers already familiar with configuring the OTel Collector via its official Helm chart. The key difference is that our solution does not implicitly change or update the logs pipeline, which avoids potential confusion from silent configuration changes. Additionally, we clearly document the use of theagents.containers.otelAgent.volumeMounts
parameter.Use Cases
1. Backward Compatibility - No Additional Volumes Mounted
In this scenario, the
filelog
receiver is defined in the OTel Collector configuration, but sincedatadog.otelCollector.logs.enabled
is not explicitly set (defaults tofalse
), no additional volumes are mounted in theotel-agent
container.This demonstrates backward compatibility by requiring explicit configuration changes to enable the new behavior.
2. Enabling Filelog Receiver Support
The customer wants to collect Kubernetes logs using the
filelog
receiver. By explicitly settingdatadog.otelCollector.logs.enabled
totrue
, additional volumes for paths/var/log/pods
,/var/log/containers
, and/var/lib/docker/containers
are mounted in theotel-agent
container.DaemonSet Diff:
3. Collecting Kubernetes Logs and Custom Logs
The customer wants to collect not only Kubernetes logs via the
filelog
receiver, but also logs from a custom location (eg./var/log/custom
). Here,datadog.otelCollector.logs.enabled
is set totrue
, and an additional volume for the custom location is defined inagents.volumes
andcontainers.otelAgent.volumeMounts
.The result is that standard volumes for Kubernetes logs, along with the custom volume, are mounted in the
otel-agent
container.DaemonSet Diff:
4. Collecting Kubernetes and Custom Logs with Core Agent Logs Collection
In this scenario, the customer is using the Core Agent for logs collection (
datadog.logs.enabled: true
), along with enabledfilelog
receiver (datadog.otelCollector.logs.enabled: true
). An additional custom volume is defined inagents.volumes
and `containers.otelAgent.volumeMounts.As a result, standard volumes for Kubernetes logs are mounted in both the core
agent
container (existing behavior) and theotel-agent
container, while the custom volume is mounted only in theotel-agent
container.DaemonSet Diff:
5. Core Agent Logs Collection with Additional Custom Volume for OTel Component
The customer uses the Core Agent for logs collection (
datadog.logs.enabled: true
) and requires an additional volume for a custom OTel component. Here, thefilelog
receiver is not defined anddatadog.otelCollector.logs.enabled
is set tofalse
, so standard volumes for Kubernetes logs are mounted only in the coreagent
container. The additional custom volume is defined for theotel-agent
container only.DaemonSet Diff:
Which issue this PR fixes
OTAGENT-286
Checklist
[Place an '[x]' (no spaces) in all applicable fields. Please remove unrelated fields.]
.github/helm-docs.sh
)CHANGELOG.md
has been updatedREADME.md