AWS Batch with ECS Fargate and the Datadog Agent
Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel,
n'hésitez pas à nous contacter.
You can run the Datadog Agent alongside your AWS Batch job containers by adding the container to your job definition.
Prerequisites
- AWS Batch compute environment
- AWS Batch job queue associated with a compute environment
Create the job definition
- Log in to your AWS Web Console and navigate to the AWS Batch section.
- Click on Job Definitions in the left menu, then click the Create button or choose an existing AWS Batch job definition.
- For new job definitions:
- Select Fargate as the orchestration type.
- Unselect Use legacy containerProperties structure option.
- Enter a Job Definition Name, such as
my-app-and-datadog
. - Select an execution IAM role. See permission requirements in the Create or Modify your IAM Policy section below.
- Enable Assign public IP to allow outbound network access, then click the Next button.
- Configure the Datadog Agent container.
- For Container name enter
datadog-agent
. - For Image enter
public.ecr.aws/datadog/agent:latest
. - Configure CPU and Memory resource requirements based on your needs.
- For Env Variables, add the Key
DD_API_KEY
and enter your Datadog API Key as the value. - Add another environment variable using the Key
ECS_FARGATE
and the value true
. Click Add to add the container. - Add another environment variable using the Key
DD_SITE
and the value
. This defaults to datadoghq.com
if you don’t set it.
- Add your other application containers to the job definition.
- AWS Batch supports [Fluentbit and Firelens][4]. To enable log collection for your application containers with Datadog:
- Create a separate log router container in the job definition.
- Configure the image
amazon/aws-for-fluent-bit:stable"
for the container. - In the Firelens Configuration section:
- Configure the Type to be
fluentbit
. - Configure the Options to include
enable-ecs-log-metadata
set to true
to the Name and Value respectively
- For your application containers, in the Log Configuration section:
- Configure the Log Driver to
awsfirelens
- Configure the Options to include the following Name and Value similar to Step 2 of the [ECS Fargate FluentBit and Firelens section][5]
- Click Create job definition to create the job definition.
Download datadog-agent-aws-batch-ecs-fargate.json.
Note: If you are using Internet Explorer, this may download as a gzip file, which contains the JSON file mentioned below.
Update the JSON with a JOB_DEFINITION_NAME
, your [Datadog API Key][41], and the appropriate DD_SITE
(
).
Note: The environment variable ECS_FARGATE
is already set to "true"
.
Add your other application containers to the job definition.
AWS Batch supports [Fluentbit and Firelens][4]. To enable log collection for your application containers with Datadog:
- In the JSON file, add an additional
log_router
container with the following in the containers
section: {
"name": "log_router",
"image": "amazon/aws-for-fluent-bit:stable",
"essential": true,
"firelensConfiguration": {
"type": "fluentbit",
"options": {
"enable-ecs-log-metadata": "true"
}
},
"resourceRequirements": [
{
"value": "0.25",
"type": "VCPU"
},
{
"value": "512",
"type": "MEMORY"
}
]
}
- In your application containers, add the relevant
logConfiguration
options similar to Step 2 of the [ECS Fargate FluentBit and Firelens section][5]
Execute the following command to register the job definition:
aws batch register-job-definition --cli-input-json file://<PATH_TO_FILE>/datadog-agent-aws-batch-ecs-fargate.json
Submit the AWS Batch job
- Log in to your AWS Web Console and navigate to the AWS Batch section. If needed, create a compute environment and/or job queue associated with a compute environment.
- On the Jobs tab, click the Submit new job button.
- Enter a Job name.
- For Job Definition, select the job created in the previous steps.
- Choose the job queue to run the Datadog Agent on.
- Container overrides are optional based on your preference.
- Click the Next button, then click the Create job button.
- Execute the following command to submit a job for your job definition:
aws batch submit-job --job-name <JOB_NAME> \
--job-queue <JOB_QUEUE_NAME> \
--job-definition <JOB_DEFINITION_NAME>:1
Further Reading
Documentation, liens et articles supplémentaires utiles: