Skip to content

Instantly share code, notes, and snippets.

@goosys
Last active October 11, 2020 06:21
Show Gist options
  • Save goosys/2521d29b008a3463e1c21926cb9f21f9 to your computer and use it in GitHub Desktop.
Save goosys/2521d29b008a3463e1c21926cb9f21f9 to your computer and use it in GitHub Desktop.
AWSTemplateFormatVersion: 2010-09-09
Metadata:
'AWS::CloudFormation::Designer':
4a374b90-9843-4f6a-a376-654dde1deb83:
size:
width: 60
height: 60
position:
x: 110
'y': 120
z: 0
embeds: []
2870f803-d96e-4a12-bda5-b083490b28c3:
size:
width: 60
height: 60
position:
x: 300
'y': 120
z: 0
embeds: []
e599b5bc-bc89-48ff-9640-4470de7956ee:
size:
width: 60
height: 60
position:
x: 190
'y': 120
z: 0
embeds: []
Resources:
Web500MetricFilter:
Type: 'AWS::Logs::MetricFilter'
Properties:
LogGroupName:
Ref: ECSAppLogGroup
FilterPattern: !Ref MetricFilterPattern
MetricTransformations:
- MetricValue: '1'
MetricNamespace: MyApplication/ECS
MetricName: !Sub
- '${PJPrefix}-web-status-500-count'
- PJPrefix: !Ref PJPrefix
Metadata:
'AWS::CloudFormation::Designer':
id: 4a374b90-9843-4f6a-a376-654dde1deb83
Web500Alerm:
Type: 'AWS::CloudWatch::Alarm'
Properties:
AlarmName: !Sub
- '${PJPrefix}-web-status-500-alerm'
- PJPrefix: !Ref PJPrefix
AlarmActions:
- Ref: Web500SNSTopic
Namespace: MyApplication/ECS
MetricName: !Sub
- '${PJPrefix}-web-status-500-count'
- PJPrefix: !Ref PJPrefix
Statistic: Sum
Period: 300
EvaluationPeriods: 1
DatapointsToAlarm: 1
Threshold: 0
ComparisonOperator: GreaterThanThreshold
TreatMissingData: notBreaching
Metadata:
'AWS::CloudFormation::Designer':
id: e599b5bc-bc89-48ff-9640-4470de7956ee
Web500SNSTopic:
Type: 'AWS::SNS::Topic'
Properties:
TopicName: !Sub
- '${PJPrefix}-web-status-500-alerm'
- PJPrefix: !Ref PJPrefix
Metadata:
'AWS::CloudFormation::Designer':
id: 2870f803-d96e-4a12-bda5-b083490b28c3
Parameters:
ECSAppLogGroup:
Type: String
Default: /ecs/logs/your-pj-name-ecs-group
PJPrefix:
Type: String
Default: your-pj-name
MetricFilterPattern:
Type: String
Default: '{$.status = 500}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment