Skip to content

Commit 667e31b

Browse files
committed
Merge pull request DataDog#686 from DataDog/ecs_improvement
add cli instructions for ecs task instructions
2 parents ef235d2 + 3fcff6c commit 667e31b

File tree

2 files changed

+99
-34
lines changed

2 files changed

+99
-34
lines changed

content/integrations/ecs.md

Lines changed: 45 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,46 +12,57 @@ Amazon EC2 Container Service (ECS) is a highly scalable, high performance contai
1212
To monitor your ECS containers and tasks with Datadog, run the Agent as a container on every EC2 instance in your ECS cluster. As detailed below, there are a few setup steps:
1313

1414
1. **Add an ECS Task**
15-
2. **Create or Modify your IAM Policy**
16-
3. **Create a new Instance with a User Script**
15+
1. **Create or Modify your IAM Policy**
16+
1. **Create a new Instance with a User Script**
1717

1818
This documentation assume you already have a working EC2 Container Service cluster configured. If not, review the [Getting Started section in the ECS documentation](http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ECS_GetStarted.html).
1919

2020
### Create an ECS Task
2121

2222
This task will launch the Datadog container. When you need to modify the configuration, you will update this Task Definition as described further down in this guide.
2323

24+
You may either configure the task using the [AWS CLI tools](https://aws.amazon.com/cli/) or using the Amazon Web Console.
25+
26+
#### AWS CLI
27+
28+
1. Download [dd-agent-ecs.json](/static/dd-agent-ecs.json).
29+
1. Edit dd-agent-ecs.json and update it with the [API_KEY](https://app.datadoghq.com/account/settings#api) for your account.
30+
1. Execute the following command:
31+
aws ecs register-task-definition --cli-input-json file://path/to/dd-agent-ecs.json
32+
33+
#### Web UI
34+
2435
1. Log in to your AWS Console and navigate to the EC2 Container Service section.
25-
2. Click on the cluster you wish to add Datadog to.
26-
3. Click on **Task Definitions** on the left side and click the button **Create new Task Definition**.
27-
4. Enter a **Task Definition Name**, such as ```dd-agent-task```.
28-
5. Click on the **Add volume** link.
29-
6. For **Name** enter ```docker_sock```. For **Source Path**, enter ```/var/run/docker.sock```. Click **Add**.
30-
7. Add another volume with the name ```proc``` and source path of ```/proc/```.
31-
8. Add another volume with the name ```cgroup``` and source path of ```/cgroup/```.
32-
9. Click the large **Add container** button.
33-
10. For **Container name** enter ```dd-agent```.
34-
11. For **Image** enter ```datadog/docker-dd-agent:ecs```.
35-
12. For **Maximum memory** enter ```128```.
36-
13. Scroll down to the **Advanced container configuration** section and enter ```10``` in **CPU units**.
37-
14. For **Env Variables**, add a **Key** of ```API_KEY``` and enter your Datadog API Key in the value. *If you feel more comfortable storing secrets like this in s3, take a [look at the ECS Configuration guide](http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-config.html#ecs-config-s3).*
38-
15. Add another Environment Variable for any tags you want to add using the key ```TAGS```.
39-
16. Scroll down to the **Storage and Logging** section.
40-
17. In **Mount points** select the **docker_sock** source volume and enter ```/var/run/docker.sock``` in the Container path. Leave the **Read only** checkbox un-checked.
41-
18. Add another mount point for **proc** and enter ```/host/proc/``` in the Container path. Check the **Read only** checkbox.
42-
19. Add a third mount point for **cgroup** and enter ```/host/sys/fs/cgroup``` in the Container path. Check the **Read only** checkbox.
36+
1. Click on the cluster you wish to add Datadog to.
37+
1. Click on **Task Definitions** on the left side and click the button **Create new Task Definition**.
38+
1. Enter a **Task Definition Name**, such as ```dd-agent-task```.
39+
1. Click on the **Add volume** link.
40+
1. For **Name** enter ```docker_sock```. For **Source Path**, enter ```/var/run/docker.sock```. Click **Add**.
41+
1. Add another volume with the name ```proc``` and source path of ```/proc/```.
42+
1. Add another volume with the name ```cgroup``` and source path of ```/cgroup/```.
43+
1. Click the large **Add container** button.
44+
1. For **Container name** enter ```dd-agent```.
45+
1. For **Image** enter ```datadog/docker-dd-agent:ecs```.
46+
1. For **Maximum memory** enter ```128```.
47+
1. Scroll down to the **Advanced container configuration** section and enter ```10``` in **CPU units**.
48+
1. For **Env Variables**, add a **Key** of ```API_KEY``` and enter your Datadog API Key in the value. *If you feel more comfortable storing secrets like this in s3, take a [look at the ECS Configuration guide](http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-agent-config.html#ecs-config-s3).*
49+
1. Add another Environment Variable for any tags you want to add using the key ```TAGS```.
50+
1. Scroll down to the **Storage and Logging** section.
51+
1. In **Mount points** select the **docker_sock** source volume and enter ```/var/run/docker.sock``` in the Container path. Leave the **Read only** checkbox un-checked.
52+
1. Add another mount point for **proc** and enter ```/host/proc/``` in the Container path. Check the **Read only** checkbox.
53+
1. Add a third mount point for **cgroup** and enter ```/host/sys/fs/cgroup``` in the Container path. Check the **Read only** checkbox.
4354

4455
### Create or Modify your IAM Policy
4556

4657
If you are modifying the IAM Policy you created for your cluster, you may only need to add one Action: ```ecs:StartTask```.
4758

4859
1. Using the Identity and Access Management (IAM) console, create a new role called ```dd-agent-ecs```.
49-
2. Select **Amazon EC2 Role for EC2 Container Service**. On the next screen do not check any checkboxes and click **Next Step**.
50-
3. Click **Create Role**.
51-
4. Click on the newly created role.
52-
5. Expand the **Inline Policies** section. Click the link to create a new inline policy.
53-
6. Choose **Custom Policy** and press the button.
54-
7. For **Policy Name** enter ```dd-agent-policy```. Copy the following text into the **Policy Document**:
60+
1. Select **Amazon EC2 Role for EC2 Container Service**. On the next screen do not check any checkboxes and click **Next Step**.
61+
1. Click **Create Role**.
62+
1. Click on the newly created role.
63+
1. Expand the **Inline Policies** section. Click the link to create a new inline policy.
64+
1. Choose **Custom Policy** and press the button.
65+
1. For **Policy Name** enter ```dd-agent-policy```. Copy the following text into the **Policy Document**:
5566

5667

5768
{
@@ -84,11 +95,11 @@ Ideally you want the Datadog agent to load on one container on each EC2 instance
8495
#### Create a new Amazon Linux instance
8596

8697
1. Log in to the AWS console and navigate to the EC2 section.
87-
2. Create a new instance by clicking the **Launch Instance** button.
88-
3. Click on Community AMIs. Visit [this page to see a list of current ECS optimized instances](http://docs.aws.amazon.com/AmazonECS/latest/developerguide/launch_container_instance.html). Choose the appropriate AMI for your region and copy the ID into the search box. Choose the AMI that comes up as a result of the search.
89-
4. Follow the prompts as you normally would when setting up an instance.
90-
5. On the third dialog, select the IAM role you created above.
91-
6. Expand the Advanced Details section and copy the following script into the User Data section. Change cluster name to your cluster's name and task definition to the name you gave your task definition.
98+
1. Create a new instance by clicking the **Launch Instance** button.
99+
1. Click on Community AMIs. Visit [this page to see a list of current ECS optimized instances](http://docs.aws.amazon.com/AmazonECS/latest/developerguide/launch_container_instance.html). Choose the appropriate AMI for your region and copy the ID into the search box. Choose the AMI that comes up as a result of the search.
100+
1. Follow the prompts as you normally would when setting up an instance.
101+
1. On the third dialog, select the IAM role you created above.
102+
1. Expand the Advanced Details section and copy the following script into the User Data section. Change cluster name to your cluster's name and task definition to the name you gave your task definition.
92103

93104
#!/bin/bash
94105
cluster="cluster_name"
@@ -116,9 +127,9 @@ Ideally you want the Datadog agent to load on one container on each EC2 instance
116127
#### Create a new CoreOS instance
117128

118129
1. Log in to the AWS console and navigate to the EC2 section.
119-
2. Create a new instance as described in the instructions for a simple CoreOS ECS instance [here](https://coreos.com/os/docs/latest/booting-on-ecs.html)).
120-
3. When you get to the Configure Instance Details step, select the IAM role you created above.
121-
4. Paste the following block in User Data under Advanced Details, replace `CLUSTER_NAME` and `YOUR_API_KEY` with the ECS cluster that instance will join and your Datadog API key. This block declares two units with cloud-config, one for the ecs-agent container, used by Amazon ECS to administrate the ECS instance, and one for the dd-agent container, used by Datadog to collect metrics about the system and the tasks running on this ECS instance. Of course it can be modified to include your own tasks as well.
130+
1. Create a new instance as described in the instructions for a simple CoreOS ECS instance [here](https://coreos.com/os/docs/latest/booting-on-ecs.html)).
131+
1. When you get to the Configure Instance Details step, select the IAM role you created above.
132+
1. Paste the following block in User Data under Advanced Details, replace `CLUSTER_NAME` and `YOUR_API_KEY` with the ECS cluster that instance will join and your Datadog API key. This block declares two units with cloud-config, one for the ecs-agent container, used by Amazon ECS to administrate the ECS instance, and one for the dd-agent container, used by Datadog to collect metrics about the system and the tasks running on this ECS instance. Of course it can be modified to include your own tasks as well.
122133

123134

124135
#cloud-config

content/static/dd-agent-ecs.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"containerDefinitions": [
3+
{
4+
"name": "dd-agent",
5+
"image": "datadog/docker-dd-agent:ecs",
6+
"cpu": 10,
7+
"memory": 128,
8+
"essential": true,
9+
"mountPoints": [
10+
{
11+
"containerPath": "/var/run/docker.sock",
12+
"sourceVolume": "docker_sock"
13+
},
14+
{
15+
"containerPath": "/host/sys/fs/cgroup",
16+
"sourceVolume": "cgroup",
17+
"readOnly": true
18+
},
19+
{
20+
"containerPath": "/host/proc ",
21+
"sourceVolume": "proc",
22+
"readOnly": true
23+
}
24+
],
25+
"environment": [
26+
{
27+
"name": "API_KEY",
28+
"value": "YOUR_API_KEY_GOES_HERE"
29+
}
30+
]
31+
}
32+
],
33+
"volumes": [
34+
{
35+
"host": {
36+
"sourcePath": "/var/run/docker.sock"
37+
},
38+
"name": "docker_sock"
39+
},
40+
{
41+
"host": {
42+
"sourcePath": "/proc/"
43+
},
44+
"name": "proc"
45+
},
46+
{
47+
"host": {
48+
"sourcePath": "/cgroup/"
49+
},
50+
"name": "cgroup"
51+
}
52+
],
53+
"family": "dd-agent-task"
54+
}

0 commit comments

Comments
 (0)