-
Notifications
You must be signed in to change notification settings - Fork 3
/
stream_subscription.yml
124 lines (119 loc) · 4.48 KB
/
stream_subscription.yml
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
service: stream-subscription-example
custom:
shardCount: 1
streamName: subscription-example-${self:provider.stage}
scaleUpAlarmName: subscription-example-scale-up-${self:provider.stage}
scaleDownAlarmName: subscription-example-scale-down-${self:provider.stage}
provider:
name: aws
region: ${opt:region, 'us-east-1'}
stage: ${opt:stage, 'dev'}
resources:
Resources:
AutoscalerExampleStream:
Type: AWS::Kinesis::Stream
Properties:
Name: ${self:custom.streamName}
ShardCount: ${self:custom.shardCount, '1'}
ScaleUpAlarm:
Type: AWS::CloudWatch::Alarm
Properties:
AlarmName: ${self:custom.scaleUpAlarmName}
AlarmActions:
- ${cf:kinesis-autoscaler-${self:provider.stage}.ScaleUpTopicArn}
Threshold: 0.75
ComparisonOperator: GreaterThanOrEqualToThreshold
TreatMissingData: ignore
EvaluationPeriods: 1
Metrics:
- Id: shardCount
Expression: ${self:custom.shardCount, '1'}
ReturnData: false
- Id: incomingBytes
MetricStat:
Metric:
Namespace: AWS/Kinesis
MetricName: IncomingBytes
Dimensions:
- Name: StreamName
Value: ${self:custom.streamName}
Period: 300
Stat: Sum
ReturnData: false
- Id: incomingRecords
MetricStat:
Metric:
Namespace: AWS/Kinesis
MetricName: IncomingRecords
Dimensions:
- Name: StreamName
Value: ${self:custom.streamName}
Period: 300
Stat: Sum
ReturnData: false
- Id: incomingBytesFilledWithZeroForMissingDataPoints
Expression: FILL(incomingBytes,0)
ReturnData: false
- Id: incomingRecordsFilledWithZeroForMissingDataPoints
Expression: FILL(incomingRecords,0)
ReturnData: false
- Id: incomingBytesUsageFactor
Expression: incomingBytesFilledWithZeroForMissingDataPoints/(1024*1024*60*5*shardCount)
ReturnData: false
- Id: incomingRecordsUsageFactor
Expression: incomingRecordsFilledWithZeroForMissingDataPoints/(1000*60*5*shardCount)
ReturnData: false
- Id: maxIncomingUsageFactor
Expression: MAX([incomingBytesUsageFactor,incomingRecordsUsageFactor])
ReturnData: true
ScaleDownAlarm:
Type: AWS::CloudWatch::Alarm
Properties:
AlarmName: ${self:custom.scaleDownAlarmName}
AlarmActions:
- ${cf:kinesis-autoscaler-${self:provider.stage}.ScaleDownTopicArn}
Threshold: 0.25
ComparisonOperator: LessThanOrEqualToThreshold
TreatMissingData: ignore
EvaluationPeriods: 288 # 86400 (day in seconds) / 300 (metric period in seconds)
Metrics:
- Id: shardCount
Expression: ${self:custom.shardCount, '1'}
ReturnData: false
- Id: incomingBytes
MetricStat:
Metric:
Namespace: AWS/Kinesis
MetricName: IncomingBytes
Dimensions:
- Name: StreamName
Value: ${self:custom.streamName}
Period: 300
Stat: Sum
ReturnData: false
- Id: incomingRecords
MetricStat:
Metric:
Namespace: AWS/Kinesis
MetricName: IncomingRecords
Dimensions:
- Name: StreamName
Value: ${self:custom.streamName}
Period: 300
Stat: Sum
ReturnData: false
- Id: incomingBytesFilledWithZeroForMissingDataPoints
Expression: FILL(incomingBytes,0)
ReturnData: false
- Id: incomingRecordsFilledWithZeroForMissingDataPoints
Expression: FILL(incomingRecords,0)
ReturnData: false
- Id: incomingBytesUsageFactor
Expression: incomingBytesFilledWithZeroForMissingDataPoints/(1024*1024*60*5*shardCount)
ReturnData: false
- Id: incomingRecordsUsageFactor
Expression: incomingRecordsFilledWithZeroForMissingDataPoints/(1000*60*5*shardCount)
ReturnData: false
- Id: maxIncomingUsageFactor
Expression: MAX([incomingBytesUsageFactor,incomingRecordsUsageFactor])
ReturnData: true