################################################################################################### #### Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. #### #### Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file #### except in compliance with the License. A copy of the License is located at #### #### http://aws.amazon.com/apache2.0/ #### #### or in the "license" file accompanying this file. This file is distributed on an "AS IS" #### BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the #### License for the specific language governing permissions and limitations under the License. ################################################################################################### ################################################################################################### #### The following file installs and configures the AWS CloudWatch Logs agent to push logs to a Log #### Group in CloudWatch Logs. #### #### The configuration below sets the logs to be pushed, the Log Group name to push the logs to and #### the Log Stream name as the instance id. The following files are examples of logs that will be #### streamed to CloudWatch Logs in near real time: #### #### /var/log/messages #### /var/log/dmesg #### #### You can then access the CloudWatch Logs by accessing the AWS CloudWatch Console and clicking #### the "Logs" link on the left. The Log Group name will follow this format: #### #### /aws/elasticbeanstalk// #### #### Please note this configuration can be used additionally to the "Log Streaming" feature: #### http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/AWSHowTo.cloudwatchlogs.html ################################################################################################### packages: yum: awslogs: [] files: "/etc/awslogs/awscli.conf" : mode: "000600" owner: root group: root content: | [plugins] cwlogs = cwlogs [default] region = `{"Ref":"AWS::Region"}` "/etc/awslogs/awslogs.conf" : mode: "000600" owner: root group: root content: | [general] state_file = /var/lib/awslogs/agent-state "/etc/awslogs/config/logs.conf" : mode: "000600" owner: root group: root content: | [/var/log/messages] log_group_name = `{"Fn::Join":["/", ["/aws/elasticbeanstalk", { "Ref":"AWSEBEnvironmentName" }, "var/log/messages"]]}` log_stream_name = {instance_id} file = /var/log/messages [/var/log/dmesg] log_group_name = `{"Fn::Join":["/", ["/aws/elasticbeanstalk", { "Ref":"AWSEBEnvironmentName" }, "var/log/dmesg"]]}` log_stream_name = {instance_id} file = /var/log/dmesg commands: "01": command: systemctl enable awslogsd.service "02": command: systemctl restart awslogsd