github.com/endocode/docker@v1.4.2-0.20160113120958-46eb4700391e/docs/reference/logging/awslogs.md (about) 1 <!--[metadata]> 2 +++ 3 title = "Amazon CloudWatch Logs logging driver" 4 description = "Describes how to use the Amazon CloudWatch Logs logging driver." 5 keywords = ["AWS, Amazon, CloudWatch, logging, driver"] 6 [menu.main] 7 parent = "smn_logging" 8 +++ 9 <![end-metadata]--> 10 11 # Amazon CloudWatch Logs logging driver 12 13 The `awslogs` logging driver sends container logs to 14 [Amazon CloudWatch Logs](https://aws.amazon.com/cloudwatch/details/#log-monitoring). 15 Log entries can be retrieved through the [AWS Management 16 Console](https://console.aws.amazon.com/cloudwatch/home#logs:) or the [AWS SDKs 17 and Command Line Tools](http://docs.aws.amazon.com/cli/latest/reference/logs/index.html). 18 19 ## Usage 20 21 You can configure the default logging driver by passing the `--log-driver` 22 option to the Docker daemon: 23 24 docker daemon --log-driver=awslogs 25 26 You can set the logging driver for a specific container by using the 27 `--log-driver` option to `docker run`: 28 29 docker run --log-driver=awslogs ... 30 31 ## Amazon CloudWatch Logs options 32 33 You can use the `--log-opt NAME=VALUE` flag to specify Amazon CloudWatch Logs logging driver options. 34 35 ### awslogs-region 36 37 The `awslogs` logging driver sends your Docker logs to a specific region. Use 38 the `awslogs-region` log option or the `AWS_REGION` environment variable to set 39 the region. By default, if your Docker daemon is running on an EC2 instance 40 and no region is set, the driver uses the instance's region. 41 42 docker run --log-driver=awslogs --log-opt awslogs-region=us-east-1 ... 43 44 ### awslogs-group 45 46 You must specify a 47 [log group](http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/WhatIsCloudWatchLogs.html) 48 for the `awslogs` logging driver. You can specify the log group with the 49 `awslogs-group` log option: 50 51 docker run --log-driver=awslogs --log-opt awslogs-region=us-east-1 --log-opt awslogs-group=myLogGroup ... 52 53 ### awslogs-stream 54 55 To configure which 56 [log stream](http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/WhatIsCloudWatchLogs.html) 57 should be used, you can specify the `awslogs-stream` log option. If not 58 specified, the container ID is used as the log stream. 59 60 > **Note:** 61 > Log streams within a given log group should only be used by one container 62 > at a time. Using the same log stream for multiple containers concurrently 63 > can cause reduced logging performance. 64 65 ## Credentials 66 67 You must provide AWS credentials to the Docker daemon to use the `awslogs` 68 logging driver. You can provide these credentials with the `AWS_ACCESS_KEY_ID`, 69 `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` environment variables, the 70 default AWS shared credentials file (`~/.aws/credentials` of the root user), or 71 (if you are running the Docker daemon on an Amazon EC2 instance) the Amazon EC2 72 instance profile. 73 74 Credentials must have a policy applied that allows the `logs:CreateLogStream` 75 and `logs:PutLogEvents` actions, as shown in the following example. 76 77 { 78 "Version": "2012-10-17", 79 "Statement": [ 80 { 81 "Action": [ 82 "logs:CreateLogStream", 83 "logs:PutLogEvents" 84 ], 85 "Effect": "Allow", 86 "Resource": "*" 87 } 88 ] 89 } 90 91