Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions content/en/agent/amazon_ecs/logs.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ To collect all logs written by running applications in your ECS containers and s

### Custom log collection

#### Configuration file

If your container writes any logs to files, follow the [Custom Log Collection documentation][1] to tail files for logs.

To gather logs from your `<APP_NAME>` application stored in `<PATH_LOG_FILE>/<LOG_FILE_NAME>.log` create a `<APP_NAME>.d/conf.yaml` file at the root of your [Agent's configuration directory][2] with the following content:
Expand All @@ -125,6 +127,12 @@ logs:

**Note**: Container metadata is not retrieved with custom log collection, therefore the Agent does not automatically assign container tags to logs. Use [custom tags][3] to create container tags.

#### Container label

With Agent v7.25.0+/6.25.0+, it is possible to enable file tailing by using a container label so the logs collected receive the tags of the container on which the label was set. See this [example][4] that details the exact label to use.

**Note**: The file paths are always relative to the Agent. So, this requires extra configuration for involved ECS tasks to share a directory between the container writing to the file and the Agent container. Refer to the [AWS documentation][5] for additional details on volume management with ECS.

## Activate log integrations

The `source` attribute is used to identify the integration to use for each container. Override it directly in your containers labels to start using [log integrations][1]. Read Datadog's [Autodiscovery guide for logs][2] to learn more about this process.
Expand All @@ -136,3 +144,5 @@ The `source` attribute is used to identify the integration to use for each conta
[1]: /agent/logs/?tab=tailfiles#custom-log-collection
[2]: /agent/logs/#custom-log-collection
[3]: /getting_started/tagging/assigning_tags/?tab=noncontainerizedenvironments#methods-for-assigning-tags
[4]: /agent/docker/log/?tab=logcollectionfromfile#examples
[5]: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/bind-mounts.html
27 changes: 26 additions & 1 deletion content/en/agent/docker/log.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Configuring log collection depends on your current environment. Choose one of th

- If you cannot deploy the containerized Agent and your container writes **all** logs to `stdout`/`stderr`, follow the [host Agent](?tab=hostagent#installation) installation to enable containerized logging within your Agent configuration file.

- If your container writes logs to files (only partially writes logs to `stdout`/`stderr` and writes logs to files OR fully writes logs to files), follow the [host Agent with custom log collection](?tab=hostagentwithcustomlogging#installation) installation.
- If your container writes logs to files (only partially writes logs to `stdout`/`stderr` and writes logs to files OR fully writes logs to files), follow the [host Agent with custom log collection](?tab=hostagentwithcustomlogging#installation) installation or follow the [containerized Agent](?tab=containerized-agent#installation) installation and check the [log collection from file with Autodiscovery configuration example](?tab=logcollectionfromfile#examples).

## Installation

Expand Down Expand Up @@ -228,6 +228,31 @@ See the [multi-line processing rule documentation][1] to get more pattern exampl


[1]: /agent/logs/advanced_log_collection/#multi-line-aggregation
{{% /tab %}}
{{% tab "From file" %}}

The Agent v7.25.0+/6.25.0+ can directly collect logs from a file based on a container Autodiscovery label. To collect these logs, use the `com.datadoghq.ad.logs` label as shown below on your containers to collect `/logs/app.log`:

```yaml
labels:
com.datadoghq.ad.logs: '[{"type":"file", "source": "sample_app", "service": "sample_service", "path": "/logs/app/prod.log"}]'
```

Logs collected from a file are tagged with the container metadata. Log collection is linked to the container life cycle, as soon as the container stops, log collection from that file stops.


**Notes**:

- The file path is **relative** to the Agent, so the directory containing the file should be shared between the container running the application and the Agent container. For example, if the container mounts `/logs` each container logging to file may mount a volume such as `/logs/app` where the log file is written.

- When using this kind of label on a container, its `stderr`/`stdout` logs are not collected automatically. If collection from both `stderr`/`stdout` and a file are needed it should be explicity enabled by using a label, for example:
```yaml
labels:
com.datadoghq.ad.logs: '[{"type":"file", "source": "java", "service": "app", "path": "/logs/app/prod.log"}, {"type": "docker", "source": "app_container", "service": "app"}]'
```

- When using this kind of combination, `source` and `service` have no default value and should be explicitly set in the Autodiscovery label.

{{% /tab %}}
{{< /tabs >}}

Expand Down