Skip to content

Commit

Permalink
[IT-3471] Create cloudwatch metrics (#25)
Browse files Browse the repository at this point in the history
Send beanstalk metrics to cloudwatch so that we can monitor beanstalk request errors.  This feature requires enhanced Beanstalk health checks[1] so we change the template always enable it and then set a ConfigDocument[2][3] to enabled the metric.

[1] https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/command-options-general.html#command-options-general-elasticbeanstalkhealthreporting
[2] https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/health-enhanced-rules.html#health-enhanced-rules.configdocument
[3] https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/health-enhanced-cloudwatch.html#health-enhanced-cloudwatch-configdocument
  • Loading branch information
zaro0508 authored Apr 8, 2024
1 parent 134dc99 commit 7a9e33f
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 11 deletions.
48 changes: 48 additions & 0 deletions config/EnhancedHealthRulesConfigDocument.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"Rules": {
"Environment": {
"Application": {
"ApplicationRequests4xx": {
"Enabled": false
},
"ApplicationRequests5xx": {
"Enabled": false
}
},
"ELB": {
"ELBRequests4xx": {
"Enabled": true
},
"ELBRequests5xx": {
"Enabled": true
}
}
}
},
"CloudWatchMetrics": {
"Environment": {
"ApplicationLatencyP99.9": 60,
"InstancesSevere": 60,
"ApplicationLatencyP90": 60,
"ApplicationLatencyP99": 60,
"ApplicationLatencyP95": 60,
"InstancesUnknown": 60,
"ApplicationLatencyP85": 60,
"InstancesInfo": 60,
"ApplicationRequests2xx": 60,
"InstancesDegraded": 60,
"InstancesWarning": 60,
"ApplicationLatencyP50": 60,
"ApplicationRequestsTotal": 60,
"InstancesNoData": 60,
"InstancesPending": 60,
"ApplicationLatencyP10": 60,
"ApplicationRequests5xx": 60,
"ApplicationLatencyP75": 60,
"InstancesOk": 60,
"ApplicationRequests3xx": 60,
"ApplicationRequests4xx": 60
}
},
"Version": 1
}
2 changes: 1 addition & 1 deletion config/agoradev/develop/agora.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ parameters:
AppHealthcheckUrl: '/about'
AutoScalingMaxSize: '4'
AutoScalingMinSize: '2'
EbHealthReportingSystem: 'enhanced'
EbDeploymentPolicy: 'RollingWithAdditionalBatch'
SnsBounceNotificationEndpoint: '[email protected]'
SnsNotificationEndpoint: '[email protected]'
Expand All @@ -24,3 +23,4 @@ parameters:
MongodbAccessSecurityGroup: !stack_output_external agora-docdb-develop::DocumentDbAccessSecurityGroup
VpcName: 'agoravpc'
CertificateArn: !stack_output_external agora-certificate::SSLCertificate
EnhancedHealthRulesConfigDocument: !file_contents config/EnhancedHealthRulesConfigDocument.json
2 changes: 1 addition & 1 deletion config/agoraprod/prod/agora.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ parameters:
AppHealthcheckUrl: '/about'
AutoScalingMaxSize: '6'
AutoScalingMinSize: '3'
EbHealthReportingSystem: 'enhanced'
EbDeploymentPolicy: 'RollingWithAdditionalBatch'
SnsBounceNotificationEndpoint: '[email protected]'
SnsNotificationEndpoint: '[email protected]'
Expand All @@ -24,3 +23,4 @@ parameters:
MongodbAccessSecurityGroup: !stack_output_external agora-docdb-prod::DocumentDbAccessSecurityGroup
VpcName: 'agoravpc-prod'
CertificateArn: !stack_output_external agora-certificate::SSLCertificate
EnhancedHealthRulesConfigDocument: !file_contents config/EnhancedHealthRulesConfigDocument.json
2 changes: 1 addition & 1 deletion config/agoraprod/staging/agora.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ parameters:
AppHealthcheckUrl: '/about'
AutoScalingMaxSize: '4'
AutoScalingMinSize: '2'
EbHealthReportingSystem: 'enhanced'
EbDeploymentPolicy: 'RollingWithAdditionalBatch'
SnsBounceNotificationEndpoint: '[email protected]'
SnsNotificationEndpoint: '[email protected]'
Expand All @@ -24,3 +23,4 @@ parameters:
MongodbAccessSecurityGroup: !stack_output_external agora-docdb-staging::DocumentDbAccessSecurityGroup
VpcName: 'agoravpc-staging'
CertificateArn: !stack_output_external agora-certificate::SSLCertificate
EnhancedHealthRulesConfigDocument: !file_contents config/EnhancedHealthRulesConfigDocument.json
15 changes: 7 additions & 8 deletions templates/beanstalk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,6 @@ Parameters:
- true
- false
ConstraintDescription: 'Valid values are true or false'
EbHealthReportingSystem:
Type: String
Default: basic
AllowedValues:
- basic
- enhanced
ConstraintDescription: must be either basic or enhanced
SnsBounceNotificationEndpoint:
Type: String
Description: Email address for SNS bounce notifications
Expand Down Expand Up @@ -86,6 +79,9 @@ Parameters:
CertificateArn:
Description: ARN of the SSL Certificate
Type: String
EnhancedHealthRulesConfigDocument:
Description: Configuration enhanced health rules (https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/health-enhanced-rules.html#health-enhanced-rules.configdocument)
Type: String
Resources:
S3AppDeployBucket:
Type: 'AWS::S3::Bucket'
Expand Down Expand Up @@ -285,7 +281,10 @@ Resources:
Value: 'HTTP'
- Namespace: 'aws:elasticbeanstalk:healthreporting:system'
OptionName: SystemType
Value: !Ref EbHealthReportingSystem
Value: 'enhanced'
- Namespace: 'aws:elasticbeanstalk:healthreporting:system'
OptionName: ConfigDocument
Value: !Ref EnhancedHealthRulesConfigDocument
- Namespace: 'aws:elasticbeanstalk:hostmanager'
OptionName: LogPublicationControl
Value: 'true'
Expand Down

0 comments on commit 7a9e33f

Please sign in to comment.