chore: tier 1 freshness: content/config/containers/logging/awslogs.md

Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
David Karlsson 2023-10-27 13:40:10 +02:00
parent 3df1949e23
commit 11d7363943
1 changed files with 23 additions and 27 deletions

View File

@ -1,10 +1,10 @@
--- ---
description: Describes how to use the Amazon CloudWatch Logs logging driver. description: Learn how to use the Amazon CloudWatch Logs logging driver with Docker Engine
keywords: AWS, Amazon, CloudWatch, logging, driver keywords: AWS, Amazon, CloudWatch, logging, driver
title: Amazon CloudWatch Logs logging driver title: Amazon CloudWatch Logs logging driver
aliases: aliases:
- /engine/reference/logging/awslogs/ - /engine/reference/logging/awslogs/
- /engine/admin/logging/awslogs/ - /engine/admin/logging/awslogs/
--- ---
The `awslogs` logging driver sends container logs to The `awslogs` logging driver sends container logs to
@ -108,7 +108,7 @@ specified, the container ID is used as the log stream.
### awslogs-create-group ### awslogs-create-group
Log driver returns an error by default if the log group does not exist. However, you can set the Log driver returns an error by default if the log group doesn't exist. However, you can set the
`awslogs-create-group` to `true` to automatically create the log group as needed. `awslogs-create-group` to `true` to automatically create the log group as needed.
The `awslogs-create-group` option defaults to `false`. The `awslogs-create-group` option defaults to `false`.
@ -128,7 +128,7 @@ $ docker run \
### awslogs-datetime-format ### awslogs-datetime-format
The `awslogs-datetime-format` option defines a multiline start pattern in [Python The `awslogs-datetime-format` option defines a multi-line start pattern in [Python
`strftime` format](https://strftime.org). A log message consists of a line that `strftime` format](https://strftime.org). A log message consists of a line that
matches the pattern and any following lines that don't match the pattern. Thus matches the pattern and any following lines that don't match the pattern. Thus
the matched line is the delimiter between log messages. the matched line is the delimiter between log messages.
@ -141,10 +141,9 @@ single entry.
This option always takes precedence if both `awslogs-datetime-format` and This option always takes precedence if both `awslogs-datetime-format` and
`awslogs-multiline-pattern` are configured. `awslogs-multiline-pattern` are configured.
> **Note** > **Note**
> >
> Multiline logging performs regular expression parsing and matching of all log > Multi-line logging performs regular expression parsing and matching of all log
> messages, which may have a negative impact on logging performance. > messages, which may have a negative impact on logging performance.
Consider the following log stream, where new log messages start with a Consider the following log stream, where new log messages start with a
@ -152,7 +151,7 @@ timestamp:
```console ```console
[May 01, 2017 19:00:01] A message was logged [May 01, 2017 19:00:01] A message was logged
[May 01, 2017 19:00:04] Another multiline message was logged [May 01, 2017 19:00:04] Another multi-line message was logged
Some random message Some random message
with some random words with some random words
[May 01, 2017 19:01:32] Another message was logged [May 01, 2017 19:01:32] Another message was logged
@ -178,7 +177,7 @@ This parses the logs into the following CloudWatch log events:
[May 01, 2017 19:00:01] A message was logged [May 01, 2017 19:00:01] A message was logged
# Second event # Second event
[May 01, 2017 19:00:04] Another multiline message was logged [May 01, 2017 19:00:04] Another multi-line message was logged
Some random message Some random message
with some random words with some random words
@ -189,7 +188,7 @@ with some random words
The following `strftime` codes are supported: The following `strftime` codes are supported:
| Code | Meaning | Example | | Code | Meaning | Example |
|:-----|:-----------------------------------------------------------------|:---------| | :--- | :--------------------------------------------------------------- | :------- |
| `%a` | Weekday abbreviated name. | Mon | | `%a` | Weekday abbreviated name. | Mon |
| `%A` | Weekday full name. | Monday | | `%A` | Weekday full name. | Monday |
| `%w` | Weekday as a decimal number where 0 is Sunday and 6 is Saturday. | 0 | | `%w` | Weekday as a decimal number where 0 is Sunday and 6 is Saturday. | 0 |
@ -212,15 +211,16 @@ The following `strftime` codes are supported:
### awslogs-multiline-pattern ### awslogs-multiline-pattern
The `awslogs-multiline-pattern` option defines a multiline start pattern using a The `awslogs-multiline-pattern` option defines a multi-line start pattern using a
regular expression. A log message consists of a line that matches the pattern regular expression. A log message consists of a line that matches the pattern
and any following lines that don't match the pattern. Thus the matched line is and any following lines that don't match the pattern. Thus the matched line is
the delimiter between log messages. the delimiter between log messages.
This option is ignored if `awslogs-datetime-format` is also configured. This option is ignored if `awslogs-datetime-format` is also configured.
> **Note**: > **Note**
> Multiline logging performs regular expression parsing and matching of all log >
> Multi-line logging performs regular expression parsing and matching of all log
> messages. This may have a negative impact on logging performance. > messages. This may have a negative impact on logging performance.
Consider the following log stream, where each log message should start with the Consider the following log stream, where each log message should start with the
@ -228,7 +228,7 @@ pattern `INFO`:
```console ```console
INFO A message was logged INFO A message was logged
INFO Another multiline message was logged INFO Another multi-line message was logged
Some random message Some random message
INFO Another message was logged INFO Another message was logged
``` ```
@ -251,7 +251,7 @@ This parses the logs into the following CloudWatch log events:
INFO A message was logged INFO A message was logged
# Second event # Second event
INFO Another multiline message was logged INFO Another multi-line message was logged
Some random message Some random message
# Third event # Third event
@ -273,13 +273,12 @@ If not specified, the container ID is used as the log stream.
> **Note** > **Note**
> >
> The CloudWatch log API does not support `:` in the log name. This can cause > The CloudWatch log API doesn't support `:` in the log name. This can cause
> some issues when using the `{{ .ImageName }}` as a tag, > some issues when using the `{{ .ImageName }}` as a tag,
> since a docker image has a format of `IMAGE:TAG`, such as `alpine:latest`. > since a Docker image has a format of `IMAGE:TAG`, such as `alpine:latest`.
> Template markup can be used to get the proper format. To get the image name > Template markup can be used to get the proper format. To get the image name
> and the first 12 characters of the container ID, you can use: > and the first 12 characters of the container ID, you can use:
> >
>
> ```bash > ```bash
> --log-opt tag='{{ with split .ImageName ":" }}{{join . "_"}}{{end}}-{{.ID}}' > --log-opt tag='{{ with split .ImageName ":" }}{{join . "_"}}{{end}}-{{.ID}}'
> ``` > ```
@ -288,7 +287,7 @@ If not specified, the container ID is used as the log stream.
### awslogs-force-flush-interval-seconds ### awslogs-force-flush-interval-seconds
The `awslogs` driver periodically flushs logs to CloudWatch. The `awslogs` driver periodically flushes logs to CloudWatch.
The `awslogs-force-flush-interval-seconds` option changes log flush interval seconds. The `awslogs-force-flush-interval-seconds` option changes log flush interval seconds.
@ -319,10 +318,7 @@ and `logs:PutLogEvents` actions, as shown in the following example.
"Version": "2012-10-17", "Version": "2012-10-17",
"Statement": [ "Statement": [
{ {
"Action": [ "Action": ["logs:CreateLogStream", "logs:PutLogEvents"],
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Effect": "Allow", "Effect": "Allow",
"Resource": "*" "Resource": "*"
} }