> ## Documentation Index
> Fetch the complete documentation index at: https://docs.subtrace.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Using Subtrace on Elastic Container Service (ECS)

> Monitor all network requests in your AWS ECS cluster using Subtrace.

If you deploy your application on AWS Elastic Container Service (ECS), Subtrace
is the easiest way to monitor the network activity in your cluster in realtime.

### Updating your ECS task to support Subtrace

1. Open **ECS** → **Task definitions**, go to your task and click **Create new revision with JSON**.
   <img src="https://mintcdn.com/subtrace/qpTd5I2XwvFUV3U2/images/ecs/5-task-update-button.png?fit=max&auto=format&n=qpTd5I2XwvFUV3U2&q=85&s=d65c5268a0de9f080207baa521036809" alt="open JSON" width="2438" height="395" data-path="images/ecs/5-task-update-button.png" />

2. In the JSON editor, add the `SYS_PTRACE` Linux capability to your container `linuxParameters` field:

   ```json theme={null}
   "linuxParameters": {
     "capabilities": {
       "add": ["SYS_PTRACE"]
     }
   },
   ```

   The `SYS_PTRACE` capability is required because it's what allows Subtrace
   to automatically monitor network activity without any code changes or root
   privileges. The ECS UI does not expose this field, hence the JSON-based
   update to the task definition.

   Set the API token that you created in the [Subtrace dashboard](https://subtrace.dev/dashboard)
   as an environment variable:

   ```json theme={null}
   "environment": [
     {
       "name": "SUBTRACE_TOKEN",
       "value": "subt_****************"
     }
   ]
   ```

   As an example, here's what the task JSON should look like:

   <img src="https://mintcdn.com/subtrace/qpTd5I2XwvFUV3U2/images/ecs/6-task-json-diff.png?fit=max&auto=format&n=qpTd5I2XwvFUV3U2&q=85&s=1c1b2a9fa0efca439ee87d87addb856f" alt="highlighted task JSON diff" width="2922" height="1479" data-path="images/ecs/6-task-json-diff.png" />

3. Click **Create** to create a new task revision.

***

### Deploying a new revision of your service

4. Back in **Clusters** → **Services** → `my-app-service`, click on **Update service**.
   <img src="https://mintcdn.com/subtrace/qpTd5I2XwvFUV3U2/images/ecs/7-service-update-click.png?fit=max&auto=format&n=qpTd5I2XwvFUV3U2&q=85&s=3611d880c39fec2486ccc6866f4d1990" alt="update service button" width="2437" height="496" data-path="images/ecs/7-service-update-click.png" />

5. In the dropdown, select the revision you just created (or leave blank for “latest”).
   <img src="https://mintcdn.com/subtrace/qpTd5I2XwvFUV3U2/images/ecs/8-service-revision.png?fit=max&auto=format&n=qpTd5I2XwvFUV3U2&q=85&s=62350a68d781e4c375fccda52bc7050b" alt="choose new revision" width="2416" height="1075" data-path="images/ecs/8-service-revision.png" />

6. Click **Update** at the bottom. ECS will spin up a new task with the new definition; when it’s healthy, the old one will be stopped.

7. Go to the Subtrace UI and see a realtime stream of all network activity in your service.
