FedRAMP customers should not enable or use the embedded OpenTelemetry Collector.
This guide explains how to build a Datadog Agent image with additional OpenTelemetry components not included in the default Datadog Agent. To see a list of components already included in the Agent by default, see Included components.
Basic understanding of the Go compilation process and Go modules.
Download the Dockerfile
Download the Dockerfile template:
Go to your preferred file location in a terminal. Run the following commands to create a new folder (for example, named agent-with-otel) and cd into it.
Creates a multi-stage build with Ubuntu 24.04 and datadog/agent:7.62.2-ot-beta-jmx.
Installs Go, Python, and necessary dependencies.
Downloads and unpacks the Datadog Agent source code.
Creates a virtual environment and installs required Python packages.
Builds the OpenTelemetry agent and copies the resulting binary to the final image.
The main branch has the most up-to-date version of the Dockerfile. However, it is a development branch that is subject to frequent changes and is less stable than the release tags. For production and other stable use cases, use the tagged versions as listed in this guide.
Create an OpenTelemetry Collector Builder manifest
Create and customize an OpenTelemetry Collector Builder (OCB) manifest file, which defines the components to be included in your custom Datadog Agent.
Open the manifest.yaml file and add the additional OpenTelemetry components to the corresponding sections (extensions, exporters, processors, receivers, or connectors).
The highlighted line in this example adds a metrics transform processor:
The custom Agent image you build needs to be stored in your organization’s private container registry for your clusters to access it. Additionally, this build process must be repeated each time you update the Agent version to maintain compatibility with new Agent releases.
Build your custom Datadog Agent image and push it to a container registry.
docker tag agent-otel <IMAGE-NAME>/<IMAGE-TAG>
docker push <IMAGE-NAME>/<IMAGE-TAG>
Replace <IMAGE-NAME> and <IMAGE-TAG> with your image name and desired tag. If the target repository is not Docker Hub, you need to include the repository name.
For a Helm chart installation, set the image tag in your values file:
Replace <YOUR-REPO> and <IMAGE-TAG> with your repository name and desired image tag.
Test and validate
Create a sample configuration file and run your custom Agent to ensure everything is working correctly.
Create a sample OpenTelemetry configuration file with the additional components.
The following example configures an additional metrics transform processor:
receivers:otlp:protocols:http:endpoint:"0.0.0.0:4318"grpc:endpoint:"0.0.0.0:4317"processors:batch:send_batch_max_size:1000send_batch_size:100timeout:10s# Rename system.cpu.usage to system.cpu.usage_timemetricstransform:transforms:- include:system.cpu.usageaction:updatenew_name:system.cpu.usage_timeexporters:datadog:api:site:${env:DD_SITE}key:${env:DD_API_KEY}connectors:datadog/connector:traces:compute_top_level_by_span_kind:truepeer_tags_aggregation:truecompute_stats_by_span_kind:trueservice:pipelines:metrics:receivers:[otlp, datadog/connector]processors:[metricstransform, batch]exporters:[datadog]traces:receivers:[otlp]processors:[batch]exporters:[datadog/connector]traces/2:receivers:[datadog/connector]processors:[batch]exporters:[datadog]logs:receivers:[otlp]processors:[batch]exporters:[datadog]
If the Agent starts, then the build process was successful.
You can now use this new image to install the Agent. This enables Datadog monitoring capabilities along with the additional OpenTelemetry components you’ve added.
Solution: Remove awscontainerinsightreceiver from the manifest.yaml file. This receiver has incompatible libraries and cannot be included in the build.
Build process failures
Problem: You receive the following error:
ERROR: failed to solve: process "/bin/sh -c . venv/bin/activate && invoke otel-agent.build" did not complete successfully: chown /var/lib/docker/overlay2/r75bx8o94uz6t7yr3ae6gop0b/work/work: no such file or directory
Solution: Run the build command again:
docker build . -t agent-otel --no-cache
Insufficient disk space
Problem: You may encounter errors related to insufficient disk space, such as:
no space left on device
Solution: Clear up Docker space:
docker system prune -a
Further reading
Additional helpful documentation, links, and articles: