This repository has been archived by the owner on Sep 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
/
marbot-elastic-beanstalk.config
93 lines (89 loc) · 3.24 KB
/
marbot-elastic-beanstalk.config
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# Setup instructions
# 1. In your Elastic Beanstalk project's source code, create a folder .ebextensions (learn more https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/ebextensions.html).
# 2. Copy this file into the .ebextensions folder (file must end with .config!).
# 3. Adjust the MarbotEndpointId option_settings.
# 4. Deploy the application.
option_settings:
aws:elasticbeanstalk:customoption:
# Your marbot endpoint ID (to get this value: select a channel where marbot belongs to and send a message like this: "@marbot show me my endpoint id").
MarbotEndpointId: ''
# The maximum percentage of CPU utilization.
MarbotCPUUtilizationThreshold: 80
# The minimum number of CPU credits available (t* instances only).
MarbotCPUCreditBalanceThreshold: 20
Resources:
MarbotTopic:
Type: 'AWS::SNS::Topic'
Properties: {}
MarbotTopicPolicy:
Type: 'AWS::SNS::TopicPolicy'
Properties:
PolicyDocument:
Id: Id1
Version: '2012-10-17'
Statement:
- Sid: Sid1
Effect: Allow
Principal:
AWS: '*'
Action: 'sns:Publish'
Resource: {Ref: MarbotTopic}
Condition:
StringEquals:
'AWS:SourceOwner': {Ref: 'AWS::AccountId'}
Topics:
- {Ref: MarbotTopic}
MarbotTopicEndpointSubscription:
DependsOn: MarbotTopicPolicy
Type: 'AWS::SNS::Subscription'
Properties:
DeliveryPolicy:
healthyRetryPolicy:
minDelayTarget: 1
maxDelayTarget: 60
numRetries: 100
numNoDelayRetries: 0
backoffFunction: exponential
throttlePolicy:
maxReceivesPerSecond: 1
Endpoint: {'Fn::Join': ['', ['https://api.marbot.io/v1/endpoint/', {'Fn::GetOptionSetting': {OptionName: MarbotEndpointId}}]]}
Protocol: https
TopicArn: {Ref: MarbotTopic}
MarbotCPUUtilizationTooHighAlarm:
DependsOn: MarbotTopicEndpointSubscription
Type: 'AWS::CloudWatch::Alarm'
Properties:
AlarmActions:
- {Ref: MarbotTopic}
AlarmDescription: 'Average CPU utilization over last 10 minutes too high. (created by marbot)'
ComparisonOperator: GreaterThanThreshold
Dimensions:
- Name: AutoScalingGroupName
Value: {Ref: AWSEBAutoScalingGroup}
EvaluationPeriods: 1
MetricName: CPUUtilization
Namespace: 'AWS/EC2'
OKActions:
- {Ref: MarbotTopic}
Period: 600
Statistic: Average
Threshold: {'Fn::GetOptionSetting': {OptionName: MarbotCPUUtilizationThreshold}}
MarbotCPUCreditBalanceTooLowAlarm:
DependsOn: MarbotTopicEndpointSubscription
Type: 'AWS::CloudWatch::Alarm'
Properties:
AlarmActions:
- {Ref: MarbotTopic}
AlarmDescription: 'Average CPU credit balance over last 10 minutes too low, expect a significant performance drop soon. (created by marbot)'
ComparisonOperator: LessThanThreshold
Dimensions:
- Name: AutoScalingGroupName
Value: {Ref: AWSEBAutoScalingGroup}
EvaluationPeriods: 1
MetricName: CPUCreditBalance
Namespace: 'AWS/EC2'
OKActions:
- {Ref: MarbotTopic}
Period: 600
Statistic: Average
Threshold: {'Fn::GetOptionSetting': {OptionName: MarbotCPUCreditBalanceThreshold}}