-
Notifications
You must be signed in to change notification settings - Fork 17
/
ACS::ECS::AlarmSpotPriceByDiscountThresholdWithMultiTypes.json
187 lines (187 loc) · 5.4 KB
/
ACS::ECS::AlarmSpotPriceByDiscountThresholdWithMultiTypes.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
{
"FormatVersion": "OOS-2019-06-01",
"Description": {
"name-en": "ACS::ECS::AlarmSpotPriceByDiscountThresholdWithMultiTypes",
"name-zh-cn": "监控多种实例类型的折扣或现价的阈值",
"en": "Alarm notification when spot instance discount or spot price exceeds threshold in multiple instance type",
"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"
},
"instanceTypes": {
"Description": {
"en": "The type of ECS instance",
"zh-cn": "ECS实例类型"
},
"Type": "List"
},
"threshold": {
"Description": {
"en": "The discount or price threshold",
"zh-cn": "折扣与现价的阈值"
},
"Type": "Number"
},
"taskType": {
"Description": {
"en": "The monitoring threshold task type",
"zh-cn": "监控阈值的任务类型"
},
"Type": "String"
}
},
"Tasks": [
{
"Name": "describeAvailableResource",
"Action": "ACS::ExecuteAPI",
"Description": {
"en": "Queries the avaliable resource",
"zh-cn": "获取可用的资源"
},
"Properties": {
"Service": "ECS",
"API": "DescribeAvailableResource",
"Parameters": {
"RegionId": "{{ regionId }}",
"InstanceType": "{{ ACS::TaskLoopItem }}",
"DestinationResource": "InstanceType",
"SpotStrategy": "SpotWithPriceLimit",
"ZoneId": "{{ zoneId }}"
}
},
"Outputs": {
"instanceType": {
"Type": "String",
"ValueSelector": ". | if .AvailableZones == \"\" then null else .AvailableZones.AvailableZone[0].AvailableResources.AvailableResource[0].SupportedResources.SupportedResource[0].Value end"
}
},
"Loop": {
"Items": "{{ instanceTypes }}",
"MaxErrors": 100,
"Concurrency": 10,
"Outputs": {
"instanceTypes": {
"AggregateType": "Fn::ListJoin",
"AggregateField": "instanceType"
}
}
}
},
{
"Name": "checkInstanceTypeSize",
"Action": "ACS::Choice",
"Description": {
"en": "Choose the next task by the count of available instance types being zero",
"zh-cn": "检测实例类型的数量是否为零"
},
"Properties": {
"DefaultTask": "describeSpotPriceHistory",
"Choices": [
{
"When": {
"Fn::Equals": [
[],
{
"Fn::MergeList": [
"{{ describeAvailableResource.instanceTypes }}"
]
}
]
},
"NextTask": "ACS::END"
}
]
}
},
{
"Name": "describeSpotPriceHistory",
"Action": "ACS::ExecuteAPI",
"Description": {
"en": "Queries the latest discounts on spot instance",
"zh-cn": "获取抢占式实例最新折扣"
},
"Properties": {
"Service": "ECS",
"API": "DescribeSpotPriceHistory",
"Parameters": {
"RegionId": "{{ regionId }}",
"InstanceType": "{{ ACS::TaskLoopItem }}",
"NetworkType": "vpc",
"ZoneId": "{{ zoneId }}"
}
},
"Outputs": {
"discountAndPrice": {
"Type": "Json",
"ValueSelector": ".SpotPrices.SpotPriceType[-1] | {\"realThreshold\":(.SpotPrice / .OriginPrice * 100), \"spotPrice\":.SpotPrice, \"originPrice\":.OriginPrice, \"instanceType\":.InstanceType}"
}
},
"Loop": {
"Items": {
"Fn::MergeList": [
"{{ describeAvailableResource.instanceTypes }}"
]
},
"MaxErrors": 100,
"Concurrency": 10,
"Outputs": {
"discountAndPrices": {
"AggregateType": "Fn::ListJoin",
"AggregateField": "discountAndPrice"
}
}
}
},
{
"Name": "alarmThresholdInfo",
"Action": "ACS::ECS::AlarmSpotPriceByDiscountThreshold",
"Description": {
"en": "Alarm notification when spot instance discount or spot price exceeds threshold",
"zh-cn": "当预付费实例的折扣与价格超出阈值时发布报警通知"
},
"Properties": {
"regionId": "{{regionId}}",
"zoneId": "{{ zoneId }}",
"discountJsonInfo": "{{ ACS::TaskLoopItem }}",
"threshold": "{{ threshold }}",
"taskType": "{{ taskType }}"
},
"Outputs": {
"instanceTypeThresholdInfos": {
"Type": "Json",
"ValueSelector": "discountInfo"
}
},
"Loop": {
"Items": "{{ describeSpotPriceHistory.discountAndPrices }}",
"MaxErrors": 100,
"Concurrency": 10,
"Outputs": {
"allInstanceTypeThresholdInfo": {
"AggregateField": "instanceTypeThresholdInfos",
"AggregateType": "Fn::ListJoin"
}
}
}
}
],
"Outputs": {
"instanceTypeThresholdInfo": {
"Type": "Json",
"Value": "{{ alarmThresholdInfo.allInstanceTypeThresholdInfo }}"
}
}
}