-
Notifications
You must be signed in to change notification settings - Fork 17
/
ACS::ECS::AlarmScalingThreshold.json
196 lines (196 loc) · 5.18 KB
/
ACS::ECS::AlarmScalingThreshold.json
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
{
"FormatVersion": "OOS-2019-06-01",
"Description": {
"name-en": "ACS::ECS::AlarmScalingThreshold",
"name-zh-cn": "当现货实例折扣或现货价格超过阈值时发出告警通知",
"en": "Alarm notification when spot instance discount or spot price exceeds threshold",
"zh-cn": "当现货实例折扣或现货价格超过阈值时发出告警通知"
},
"Parameters": {
"regionId": {
"Description": {
"en": "The ID of region",
"zh-cn": "地域ID"
},
"Type": "String"
},
"zoneId": {
"Description": {
"en": "The ID of zone",
"zh-cn": "可用区ID"
},
"Type": "String"
},
"discountJsonInfo": {
"Description": {
"en": "The discount info",
"zh-cn": "折扣信息"
},
"Type": "Json"
},
"threshold": {
"Description": {
"en": "The discount or price threshold",
"zh-cn": "折扣或价格门槛"
},
"Type": "Number"
},
"scalingGroupId": {
"Description": {
"en": "The ID of scaling group",
"zh-cn": "伸缩组ID"
},
"Type": "String"
},
"taskType": {
"Description": {
"en": "The monitoring threshold task type",
"zh-cn": "监控阈值任务类型"
},
"Type": "String"
}
},
"Tasks": [
{
"Name": "selectTask",
"Action": "ACS::Choice",
"Description": {
"en": "Select the type of task that performs the monitoring threshold",
"zh-cn": "选择执行监控阈值的任务类型"
},
"Properties": {
"DefaultTask": "ACS::END",
"Choices": [
{
"When": {
"Fn::Equals": [
"Discount",
"{{ taskType }}"
]
},
"NextTask": "checkDiscountThreshold"
},
{
"When": {
"Fn::Equals": [
"Price",
"{{ taskType }}"
]
},
"NextTask": "checkSpotPriceThreshold"
}
]
}
},
{
"Name": "checkDiscountThreshold",
"Action": "ACS::Choice",
"Description": {
"en": "Check if the actual discount exceeds the threshold",
"zh-cn": "检查实际折扣是否超过阈值"
},
"Properties": {
"DefaultTask": "ACS::END",
"Choices": [
{
"When": {
"Fn::Equals": [
true,
{
"Fn::Jq": [
"First",
".realThreshold >= {{ threshold }}",
"{{ discountJsonInfo }}"
]
}
]
},
"NextTask": "describeSpotPriceHistory"
}
]
}
},
{
"Name": "checkSpotPriceThreshold",
"Action": "ACS::Choice",
"Description": {
"en": "Check if the actual discount exceeds the threshold",
"zh-cn": "检查实际折扣是否超过阈值"
},
"Properties": {
"DefaultTask": "ACS::END",
"Choices": [
{
"When": {
"Fn::Equals": [
true,
{
"Fn::Jq": [
"First",
".spotPrice >= {{ threshold }}",
"{{ discountJsonInfo }}"
]
}
]
},
"NextTask": "describeSpotPriceHistory"
}
]
}
},
{
"Name": "describeSpotPriceHistory",
"Action": "ACS::ExecuteAPI",
"Description": {
"en": "Queries the latest discounts or spot price on spot instance",
"zh-cn": "在现货实例上获得最新的折扣或现货价格"
},
"Properties": {
"Service": "ECS",
"API": "DescribeSpotPriceHistory",
"Parameters": {
"RegionId": "{{ regionId }}",
"InstanceType": {
"Fn::Jq": [
"First",
".instanceType",
"{{ discountJsonInfo }}"
]
},
"NetworkType": "vpc",
"ZoneId": "{{ zoneId }}"
}
},
"Outputs": {
"spotPrice": {
"Type": "String",
"ValueSelector": ".SpotPrices.SpotPriceType[-1].SpotPrice"
},
"instanceType": {
"Type": "String",
"ValueSelector": ".SpotPrices.SpotPriceType[-1].InstanceType"
},
"zoneId": {
"Type": "String",
"ValueSelector": ".SpotPrices.SpotPriceType[-1].ZoneId"
},
"actualDiscount": {
"Type": "String",
"ValueSelector": ".SpotPrices.SpotPriceType[-1] | .SpotPrice / .OriginPrice * 10000 | floor as $num | $num/100"
}
}
}
],
"Outputs": {
"discountInfo": {
"Type": "Json",
"Value": {
"scalingGroupId": "{{ scalingGroupId }}",
"instanceType": "{{ describeSpotPriceHistory.instanceType }}",
"zoneId": "{{ describeSpotPriceHistory.zoneId }}",
"spotPrice": "{{ describeSpotPriceHistory.spotPrice }}",
"actualDiscount": "{{ describeSpotPriceHistory.actualDiscount }}"
}
}
}
}