> For the complete documentation index, see [llms.txt](https://docs.controltheory.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.controltheory.com/controltheory-documentation/dstl8-docs/sources/amazon-ecs.md).

# Amazon ECS

Get logs, metrics and traces from Amazon ECS services into Dstl8.

Send logs from your Amazon ECS services, on Fargate or EC2, to Dstl8, and metrics and traces too if your services use OpenTelemetry. There is no separate ECS source type: you use the source that matches how your tasks already emit telemetry.

### Choose your path

| If your tasks...                                                               | Use                                                                 |
| ------------------------------------------------------------------------------ | ------------------------------------------------------------------- |
| write container stdout/stderr to CloudWatch Logs with the `awslogs` log driver | [Path 1: AWS CloudWatch source](#path-1-aws-cloudwatch-recommended) |
| already run an OpenTelemetry collector or SDKs, or you want metrics and traces | [Path 2: OpenTelemetry source](#path-2-opentelemetry-otlp)          |

If you're not sure which applies, check a task definition's log driver:

```bash
aws ecs describe-task-definition --task-definition <family> \
  --query "taskDefinition.containerDefinitions[].{name:name,driver:logConfiguration.logDriver,options:logConfiguration.options}"
```

`driver` of `awslogs` means Path 1.

### Path 1: AWS CloudWatch (recommended)

This needs no changes to your tasks beyond logging to CloudWatch Logs. A CloudFormation stack that you launch from Dstl8 forwards your log groups to Dstl8; see [AWS CloudWatch](https://docs.controltheory.com/controltheory-documentation/dstl8-docs/sources/aws-cloudwatch.md) for the full walkthrough, permissions and options.

#### 1. Make sure your tasks log to CloudWatch

In each container definition, use the `awslogs` driver. Using the `/ecs/<service>` log group naming lets Dstl8 recognize the logs as ECS:

```json
"logConfiguration": {
  "logDriver": "awslogs",
  "options": {
    "awslogs-group": "/ecs/<service-name>",
    "awslogs-region": "<region>",
    "awslogs-stream-prefix": "ecs",
    "awslogs-create-group": "true"
  }
}
```

The task execution role needs `logs:CreateLogStream` and `logs:PutLogEvents` (the AWS managed policy `AmazonECSTaskExecutionRolePolicy` includes them), plus `logs:CreateLogGroup` if you use `awslogs-create-group`.

#### 2. Create the source and launch the stack

1. From **Sources**, click **Add Source**, select **AWS CloudWatch**, name it, and click **Create**.
2. On **Connect your AWS account**, pick the region your ECS cluster runs in.
3. Choose **All log groups**, or **Only the log groups I choose** and tick your `/ecs/...` groups. See [Choose what's sent](https://docs.controltheory.com/controltheory-documentation/dstl8-docs/sources/aws-cloudwatch.md#choose-whats-sent).
4. Click **Launch stack in AWS**, acknowledge the IAM and transform notices, and click **Create stack**.

#### 3. Verify

Dstl8 shows **Listening for first data**, then **Receiving logs**, usually within a minute or two. The source turns **Healthy** and each log group appears as a stream of type `ecs`, named for the service (for example, `/ecs/orders` becomes the stream `orders`). Assign the streams to a workspace as described in [Assigning streams to workspaces](https://docs.controltheory.com/controltheory-documentation/dstl8-docs/sources.md#assigning-streams-to-workspaces).

Each AWS region needs its own stack, all sending to the same source.

### Path 2: OpenTelemetry (OTLP)

If your services already send OpenTelemetry data to a collector (a sidecar, or a shared gateway service in the cluster), add Dstl8 as another exporter. This path carries logs, metrics and traces. Create an **OpenTelemetry** source as described in [OpenTelemetry (OTel)](https://docs.controltheory.com/controltheory-documentation/dstl8-docs/sources/opentelemetry-otel.md), then add an exporter to your collector's configuration:

```yaml
exporters:
  otlphttp/dstl8:
    endpoint: https://<org_id>.app.dstl8.ai/src-<id>
    headers:
      Authorization: "Bearer <YOUR_OTLP_TOKEN>"

service:
  pipelines:
    logs:
      exporters: [otlphttp/dstl8]   # keep your existing exporters in these lists too
    metrics:
      exporters: [otlphttp/dstl8]
    traces:
      exporters: [otlphttp/dstl8]
```

Add the exporter alongside your current ones so your existing destination keeps receiving data. Store the bearer token in AWS Secrets Manager or SSM Parameter Store and inject it into the task as a secret, rather than putting it in the task definition as plain text.

Set `service.name` on your telemetry: it names your log streams and the services your metrics and traces are filed under. The OpenTelemetry resource detector for ECS adds the task and cluster details. Services sending straight from an SDK, without a collector, can use the same endpoint; see [OpenTelemetry SDK](https://docs.controltheory.com/controltheory-documentation/dstl8-docs/sources/opentelemetry-otel.md#opentelemetry-sdk-environment-variables).

The endpoint accepts OTLP over HTTP only, so use the `otlphttp` exporter (not `otlp`, which is gRPC).

### Troubleshooting

| Symptom                                       | What to check                                                                                                                                                                                                                                                            |
| --------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| No streams appear (Path 1)                    | Confirm the tasks are actually writing to the log group, and that the stack's region matches the log group's region. See [If logs stop arriving](https://docs.controltheory.com/controltheory-documentation/dstl8-docs/sources/aws-cloudwatch.md#if-logs-stop-arriving). |
| Log groups missing                            | Only Standard-class log groups can be forwarded. Infrequent Access groups can't.                                                                                                                                                                                         |
| Stack creation fails                          | You need permission to create the IAM roles, Firehose stream and S3 bucket; see **Before you start** on the CloudWatch page.                                                                                                                                             |
| OTLP data rejected (Path 2)                   | Check the endpoint includes your `/src-<id>` path, the `Authorization: Bearer` header holds the token for that source, and the exporter is `otlphttp`.                                                                                                                   |
| Logs arrive but no metrics or traces (Path 2) | Add the exporter to the collector's `metrics` and `traces` pipelines too.                                                                                                                                                                                                |

### Uninstall

* **Path 1:** delete the stack in each region you launched it. Deleting the source in Dstl8 doesn't remove the stack.
* **Path 2:** remove the exporter from your collector configuration, then delete the source.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.controltheory.com/controltheory-documentation/dstl8-docs/sources/amazon-ecs.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
