Descripción general

En un contenedor de Docker Linux, utilice la instrumentación de un solo paso (SSI) para APM a fin de instalar el Datadog Agent e instrumentar sus aplicaciones en un solo paso, sin necesidad de configuración adicional.

Configure APM con un Agent

Install the dd-apm skill in your AI coding agent for guided APM setup.
npx skills add https://github.com/datadog-labs/agent-skills --skill dd-apm --full-depth -y

Habilite APM en sus aplicaciones

Antes de continuar, confirme que su entorno sea compatible revisando la guía de compatibilidad de SSI.

Para instalar el Datadog Agent y habilitar SSI en un entorno Docker de Linux, ejecute los siguientes comandos en su servidor Docker (no dentro de un contenedor de aplicación).

  1. Instale los componentes de instrumentación de Docker sin instalar un Agent en el servidor:

    DD_APM_INSTRUMENTATION_ENABLED=docker \
    DD_NO_AGENT_INSTALL=true \
    bash -c "$(curl -L https://install.datadoghq.com/scripts/install_script_agent7.sh)"
    
  2. Ejecute o vuelva a implementar el contenedor del Agent. Reemplace <YOUR_DD_API_KEY> con su clave de Datadog API:

    docker run -d --name dd-agent \
      -e DD_API_KEY=<YOUR_DD_API_KEY> \
      -e DD_SITE="" \
      -e DD_DOGSTATSD_NON_LOCAL_TRAFFIC=true \
      -e DD_APM_ENABLED=true \
      -e DD_APM_NON_LOCAL_TRAFFIC=true \
      -e DD_APM_RECEIVER_SOCKET=/var/run/datadog/apm.socket \
      -e DD_DOGSTATSD_SOCKET=/var/run/datadog/dsd.socket \
      -v /var/run/datadog:/var/run/datadog \
      -v /var/run/docker.sock:/var/run/docker.sock:ro \
      -v /proc/:/host/proc/:ro \
      -v /sys/fs/cgroup/:/host/sys/fs/cgroup:ro \
      -v /var/lib/docker/containers:/var/lib/docker/containers:ro \
      registry.datadoghq.com/agent:7
    

    Note: Run only one Datadog Agent per node. If a Datadog Agent container already exists, update its definition (or your Docker Compose file) with these settings and recreate it, rather than starting a second Agent. For rootless Docker, set the correct Docker socket in docker_config.yaml.

  3. Recreate your application containers.

    Instrumentation is applied when a container is created, so restarting an existing container with docker stop and docker start does not instrument it. Remove your application containers and run them again.

SSI adds a small amount of startup time to instrumented applications. If this overhead is not acceptable for your use case, contact Datadog Support.

Generate the command from Datadog

To get a command pre-filled with your API key and site, go to the Install the Datadog Agent on Docker page. In the Customize my agent install command section, go to Additional configuration > Application Observability, and turn on APM Instrumentation. Then copy and run the generated command.

La sección 'Customize your agent install command' de las instrucciones en la aplicación para instalar el Datadog Agent en Docker

Establecer versiones del rastreador del SDK

De forma predeterminada, Single Step Instrumentation instala las versiones principales más recientes de los SDK de Datadog y aplica actualizaciones menores automáticamente cuando están disponibles.

Para fijar versiones específicas, agregue la variable DD_APM_INSTRUMENTATION_LIBRARIES con pares language:major separados por comas al comando de instalación del componente. Las versiones disponibles se enumeran en los repositorios de fuente para cada lenguaje:

También puede seleccionar versiones desde los menús desplegables en Datadog: en la página Install the Datadog Agent on Docker, después de activar APM Instrumentation, haga clic en Customize library versions.

El menú desplegable 'Customize library versions' en las instrucciones para instalar el Datadog Agent en Docker

Verifique la instalación

  1. Confirme que el demonio de Docker esté utilizando el tiempo de ejecución de Datadog:

    docker system info --format '{{.DefaultRuntime}}'
    

    The output must be dd-shim. If it is runc or anything else, the instrumentation components did not install successfully, and your applications are not instrumented regardless of whether the Agent is healthy. Re-run the installation command, and confirm that the Docker daemon was running when you ran it.

  2. Confirm the Agent container is running:

    docker ps --filter name=dd-agent
    
  3. Confirme que el Agent esté en buen estado y que el APM Agent se esté ejecutando:

    docker exec dd-agent agent status
    

    Verifique la sección APM Agent de la salida.

  4. Confirme que un contenedor de aplicación esté utilizando el tiempo de ejecución de Datadog. Reemplace <CONTAINER_NAME> con el nombre de uno de sus contenedores de aplicación:

    docker inspect <CONTAINER_NAME> --format '{{.HostConfig.Runtime}}'
    
  5. After your applications receive traffic, confirm your services appear on the APM Services page. If they don’t appear within a few minutes, follow the SSI troubleshooting guide.

Configure Unified Service Tags

Unified Service Tags (USTs) apply consistent tags across traces, metrics, and logs, making it easier to navigate and correlate your observability data. Learn how to set USTs for Docker services.

Enable SDK-dependent products and features

After SSI loads the Datadog SDK into your applications and enables distributed tracing, you can configure additional products that rely on the SDK:

ProductEnvironment variable
Runtime MetricsDD_RUNTIME_METRICS_ENABLED
Log InjectionDD_LOGS_INJECTION
Continuous ProfilerDD_PROFILING_ENABLED
Data Streams MonitoringDD_DATA_STREAMS_ENABLED
App and API ProtectionDD_APPSEC_ENABLED
Runtime Code Analysis (IAST)DD_IAST_ENABLED
Dynamic InstrumentationDD_DYNAMIC_INSTRUMENTATION_ENABLED
Data Jobs MonitoringDD_DATA_JOBS_ENABLED
Software Composition AnalysisDD_APPSEC_SCA_ENABLED

Note: All variables accept true or false. DD_PROFILING_ENABLED also accepts auto, which profiles only eligible processes and is recommended for SSI.

Para habilitar productos, configure variables de entorno en la configuración de su aplicación.

Elimine la instrumentación de Single Step APM de su Agent

Si no desea recopilar datos de traza para un servicio, servidor, VM o contenedor en particular, complete los siguientes pasos:

Eliminar la instrumentación de servicios específicos

Para eliminar la instrumentación de APM y dejar de enviar trazas desde un servicio específico:

  1. Agregue la variable de entorno DD_INSTRUMENT_SERVICE_WITH_APM al comando de inicio del servicio:
    docker run -e DD_INSTRUMENT_SERVICE_WITH_APM=false <service_start_command>
    
  2. Reinicie el servicio.

Eliminar APM para todos los servicios en la infraestructura

Para dejar de producir trazas, desinstale APM y reinicie la infraestructura:

  1. Ejecute:
    dd-container-install --uninstall
    
  2. Reinicie Docker:
    systemctl restart docker
    
    O utilice el equivalente para su entorno.

Solución de problemas

Si encuentra problemas al habilitar APM con SSI, consulte la guía de solución de problemas de SSI.

Lecturas adicionales

Documentación, enlaces y artículos útiles adicionales: