Skip to content

Instantly share code, notes, and snippets.

@dejanvasic85
Last active March 5, 2020 05:36
Show Gist options
  • Save dejanvasic85/2c3b9045f8e5cdf40006005cd7a15970 to your computer and use it in GitHub Desktop.
Save dejanvasic85/2c3b9045f8e5cdf40006005cd7a15970 to your computer and use it in GitHub Desktop.
Elastic Beanstalk Setup Cloudwatch custom logs
###################################################################################################
#### 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/<environment name>/<full log name path>
####
#### 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/containers/talentsearch-api/talentsearch-api-*.json]
log_group_name = talentsearch-api-__ENV__-logs
log_stream_name = {instance_id}
file = /var/log/containers/talentsearch-api/talentsearch-api-*.json
commands:
"01":
command: chkconfig awslogs on
"02":
command: service awslogs restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment