Esta guía explica cómo crear una imagen del Datadog Agent con componentes adicionales de OpenTelemetry no incluidos en la imagen por defecto del Datadog Agent. Para ver una lista de los componentes ya incluidos en el Agent por defecto, consulta Componentes incluidos.
Conocimientos básicos del proceso de compilación Go y de los módulos Go.
Descargar el archivo Docker
Descargue la plantilla del archivo Docker:
Ve a tu localización de archivos preferida en un terminal. Ejecuta los siguientes comandos para crear una nueva carpeta (por ejemplo, llamada agent-with-otel) y cd en ella.
Crea una compilación multietapa con Ubuntu v24.04 y datadog/agent:7.59.0-v1.1.0-ot-beta-jmx.
Instala Go, Python y las dependencias necesarias.
Descarga y descomprime el código fuente del Datadog Agent.
Crea un entorno virtual e instala los paquetes Python necesarios.
Crea el Agent OpenTelemetry y copia el binario resultante en la imagen final.
Crear un manifiesto de OpenTelemetry Collector Builder
Crea y personaliza un archivo del manifiesto de OpenTelemetry Collector Builder (OCB), que defina los componentes que se incluirán en tu Datadog Agent personalizado.
Abre el archivo manifest.yaml y añade los componentes adicionales de OpenTelemetry a las secciones correspondientes (extensiones, exportadores, procesadores, receptores o conectores).
La línea resaltada en este ejemplo añade un procesador de transformación de métricas:
Crea tu imagen personalizada del Datadog Agent y envíala a un registro de contenedor.
Crea la imagen con Docker:
docker build . -t agent-otel --no-cache
Tag and push the image:
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
Espacio en disco insuficiente
Problema: Puedes encontrarte con errores relacionados con la insuficiencia de espacio en el disco, como: