AWS Batch with ECS Fargate and the Datadog Agent
This page is not yet available in Spanish. We are working on its translation.
If you have any questions or feedback about our current translation project,
feel free to reach out to us!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.
- 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.
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
Additional helpful documentation, links, and articles: