Esta página aún no está disponible en español. Estamos trabajando en su traducción.
Si tienes alguna pregunta o comentario sobre nuestro actual proyecto de traducción, no dudes en ponerte en contacto con nosotros.

Datadog Container Monitoring enables visibility into applications running on Amazon ECS Managed Instances.

How it works

To monitor your ECS Managed Instances tasks with Datadog, run the Datadog Agent as a container in same task definition as your application container. When a Datadog Agent is run as an additional container within an ECS task definition, the Agent can use the task’s metadata endpoint to collect data. This endpoint returns a Docker stats JSON for all containers associated with the task.

For more information about the collected Docker stats, see Docker API: ContainerStats in the Docker documentation.

Setup

This setup requires Datadog Agent 7.73.0+.

The following instructions assume that you have configured an ECS Managed Instances cluster. See the Amazon ECS Managed Instances documentation for creating a cluster.

  1. Create an ECS Managed Instances task definition file
  2. Register the task definition
  3. Run the task as a replica service

Create an ECS Managed Instances task definition file

This ECS task definition launches the Datadog Agent container with the necessary configurations.

  1. Download datadog-agent-ecs-managed-instances-sidecar.json. This files provide minimal configuration for core infrastructure monitoring. For more sample task definition files with various features enabled, see the Set up additional Agent features section on this page.
  2. Modify the task definition file:
  3. (Optional) To add an Agent health check, add the following line to your ECS task definition:
    "healthCheck": {
      "retries": 3,
      "command": ["CMD-SHELL","agent health"],
      "timeout": 5,
      "interval": 30,
      "startPeriod": 15
    }
    

Register the task definition

  1. Log in to your AWS Console and navigate to the Elastic Container Service section.
  2. Select Task Definitions in the navigation pane. On the Create new task definition menu, select Create new task definition with JSON.
  3. In the JSON editor box, paste the contents of your task definition file.
  4. Select Create.

Use the AWS CLI to execute the following command:

aws ecs register-task-definition --cli-input-json file://<path to datadog-agent-ecs-managed-instances-sidecar.json>

Run the task as a replica service

Because ECS Managed Instances does not support daemon scheduling, run the task as a replica service.

  1. Log in to your AWS Web Console and navigate to the Elastic Container Service section.
  2. Choose the cluster to run the Datadog Agent on.
  3. On the Services tab, click Create.
  4. For Task Definition, select the task created in the previous steps.
  5. Enter a Service name.
  6. For Launch type, choose Capacity Provider and select the Manged Instance capacity provider tied to the cluster.
  7. For Number of tasks, enter 1. Click Next step.
  8. Fill in the rest of the optional fields based on your preference.
  9. Click Next step.
  10. Click Create service.

Use the AWS CLI to execute the following command:

aws ecs create-service --cluster <CLUSTER_NAME> \
--service-name <SERVICE_NAME> \
--task-definition <TASK_DEFINITION_ARN> \
--desired-count 1 \
--network-configuration "awsvpcConfiguration={subnets=[subnet-abcd1234],securityGroups=[sg-abcd1234]}"

Set up additional Datadog Agent features

Metrics collection

Docker labels are not supported for ECS Managed Instances. To provide a custom integration configuration, you must mount a configuration file directly onto the Datadog Agent container.

Example: Setting up a Datadog Agent with custom configuration files mounted

Create the following file structure:

|- datadog
  |- Dockerfile
  |- conf.d
    |-redis.yaml

The redis.yaml file contains the configurations for the Redis integration.

redis.yaml

ad_identifiers:
  - redis

init_config:

instances:
    - host: %%host%%
      port: 6379

The Dockerfile is used to build a Datadog Agent image and include the redis.yaml file at the correct location:

Dockerfile

FROM public.ecr.aws/datadog/agent:latest

COPY conf.d/ /etc/datadog-agent/conf.d/

After the image is built and pushed to an image registry, reference the custom image in the ECS task definition:

{
    "containerDefinitions": [
        {
            "image": "<registry-domain>/<namespace-or-account>/<repository>:<tag>",
            "name": "datadog-agent",
            ...
        }
    ],
    ...
}

Trace collection (APM)

Instrument your application based on your setup:

UDP

To collect traces over UDP, do not set DD_AGENT_HOST. Keep the default localhost value.

UDS

To collect traces over UDS:

  1. Add an empty volume onto the task definition using the volumes parameter.
  2. Mount the volume onto the agent and application container using the mountPoints parameter.
  3. Configure the environmental variable DD_DOGSTATSD_SOCKET on the application container and set it to /var/run/datadog/dsd.socket.

Example: Container definitions that configure collecting traces over UDS

{
    "containerDefinitions": [
        {
            "image": "datadog/agent:latest",
            "mountPoints": [
                {
                    "containerPath": "/var/run/datadog",
                    "readOnly": false,
                    "sourceVolume": "dd-sockets"
                }
            ],
            "name": "datadog-agent",
            ...
            ...
        },
        {
            "environment": [
                {
                    "name": "DD_DOGSTATSD_SOCKET",
                    "value": "/var/run/datadog/dsd.socket"
                }
            ],
            "mountPoints": [
                {
                    "containerPath": "/var/run/datadog",
                    "readOnly": false,
                    "sourceVolume": "dd-sockets"
                }
            ],
            "name": "app",
            ...
            ...
        }
    ],
    ...
    "volumes": [
        {
            "host": {},
            "name": "dd-sockets"
        }
    ]
}

Log collection

The setup for log collection is identical to the setup for log collection in ECS Fargate. Follow the instructions in the ECS Fargate documentation. These instructions give you the option to use either AWS FireLens in combination with Datadog’s Fluent Bit output plugin, or the awslogs log driver.

Process collection

You can monitor processes in ECS Managed Instances in Datadog by using the Live Processes page. To enable process collection, add the PidMode parameter in the task definition and set it to task as follows:

"pidMode": "task"

Troubleshooting

Need help? Contact Datadog support.

Further reading