Skip to content

Instantly share code, notes, and snippets.

@mdesanti
Created October 28, 2016 12:49
Show Gist options
  • Save mdesanti/16081484c68eafd3a213371e8972b32d to your computer and use it in GitHub Desktop.
Save mdesanti/16081484c68eafd3a213371e8972b32d to your computer and use it in GitHub Desktop.
# Store Puma Application Logs in Cloudwatch
Mappings:
CWLogs:
PumaLogGroup:
LogFile: "/var/log/puma/puma.log"
TimestampFormat: ""
Outputs:
PumaCWLogGroup:
Description: "Puma Application Logs"
Value: { "Ref" : "AWSEBCloudWatchLogs8832c8d3f1a54c238a40e36f31ef55a0PumaLogGroup"}
Resources :
AWSEBCloudWatchLogs8832c8d3f1a54c238a40e36f31ef55a0PumaLogGroup: ## Must have prefix: AWSEBCloudWatchLogs8832c8d3f1a54c238a40e36f31ef55a0
Type: "AWS::Logs::LogGroup"
DependsOn: AWSEBBeanstalkMetadata
DeletionPolicy: Retain ## this is required
Properties:
LogGroupName:
"Fn::GetOptionSetting":
Namespace: "aws:elasticbeanstalk:application:environment"
OptionName: PumaCWLogGroup
DefaultValue: {"Fn::Join":["-", [{ "Ref":"AWSEBEnvironmentName" }, "puma"]]}
RetentionInDays: 14
## Register the files/log groups for monitoring
AWSEBAutoScalingGroup:
Metadata:
"AWS::CloudFormation::Init":
CWLogsAgentConfigSetup:
files:
## any .conf file put into /tmp/cwlogs/conf.d will be added to the cwlogs config (see cwl-agent.config)
"/tmp/cwlogs/conf.d/puma.conf":
content : |
[nodjs-log]
file = `{"Fn::FindInMap":["CWLogs", "PumaLogGroup", "LogFile"]}`
log_group_name = `{ "Ref" : "AWSEBCloudWatchLogs8832c8d3f1a54c238a40e36f31ef55a0PumaLogGroup" }`
log_stream_name = {instance_id}
datetime_format = `{"Fn::FindInMap":["CWLogs", "PumaLogGroup", "TimestampFormat"]}`
mode : "000400"
owner : root
group : root
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment