-
Notifications
You must be signed in to change notification settings - Fork 17
/
ACS::ECS::AlarmSpotPriceOrDiscountThresholdByScalingGroup.yml
113 lines (113 loc) · 3.64 KB
/
ACS::ECS::AlarmSpotPriceOrDiscountThresholdByScalingGroup.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
FormatVersion: OOS-2019-06-01
Description:
name-en: ACS::ECS::AlarmSpotPriceOrDiscountThresholdByScalingGroup
name-zh-cn: 监控伸缩组内实例的现价或折扣的阈值
en: Alarm notification when spot instance discount or spot price exceeds threshold in the scaling group
zh-cn: 监控弹性伸缩组弹出的预付费实例的最新价格与折扣,超出阈值时发出报警通知
Parameters:
regionId:
Description:
en: The ID of region
zh-cn: 地域ID
Type: String
zoneIds:
Description:
en: The ID of zone
zh-cn: 可用区ID
Type: List
threshold:
Description:
en: 'The discount threshold(example:10 is 1% off, 50 is 50% off)'
zh-cn: 折扣阈值(例:输入10是1折,50为5折)
Type: Number
taskType:
Description:
en: Monitoring threshold task type
zh-cn: 监控阈值的任务类型
Type: String
vSwitchId:
Description:
en: Query vswitch id for zone id
zh-cn: 为了可用区ID而查询的交换机
Type: String
scalingGroupId:
Description:
en: The ID of scaling group
zh-cn: 伸缩组ID
Type: String
scalingConfigurationId:
Description:
en: The ID of scaling configuration
zh-cn: 伸缩配置ID
Type: String
configurationInfos:
Description:
en: The scaling configuration infos
zh-cn: 伸缩配置信息
Type: List
Tasks:
- 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:
'Fn::Jq':
- First
- '.| map(select(.vSwitchId == "{{ vSwitchId }}").zoneId)[]'
- '{{ zoneIds }}'
Outputs:
discountAndPrice:
Type: Json
ValueSelector: '.SpotPrices.SpotPriceType[-1] | {"realThreshold":(.SpotPrice / .OriginPrice * 100), "spotPrice":.SpotPrice, "originPrice":.OriginPrice, "instanceType":.InstanceType}'
Loop:
Items:
'Fn::Jq':
- First
- '. | map(select(.scalingConfigurationId = "{{ scalingConfigurationId }}").instanceTypes)[]'
- '{{ ConfigurationInfos }}'
MaxErrors: 100
Concurrency: 10
Outputs:
discountAndPrices:
AggregateType: 'Fn::ListJoin'
AggregateField: discountAndPrice
- Name: alarmThresholdInfo
Action: 'ACS::ECS::AlarmScalingThreshold'
Description:
en: Alarm notification when spot instance discount or spot price exceeds threshold
zh-cn: 监控预付费实例的最新折扣与价格,超过阈值时发出报警通知
Properties:
regionId: '{{regionId}}'
zoneId:
'Fn::Jq':
- First
- '.| map(select(.vSwitchId == "{{ vSwitchId }}").zoneId)[]'
- '{{ zoneIds }}'
discountJsonInfo: '{{ ACS::TaskLoopItem }}'
threshold: '{{ threshold }}'
scalingGroupId: '{{ scalingGroupId }}'
taskType: '{{ taskType }}'
Outputs:
instanceTypeThresholdInfos:
Type: Json
ValueSelector: discountInfo
Loop:
Items: '{{ describeSpotPriceHistory.discountAndPrices }}'
MaxErrors: 100
Concurrency: 10
Outputs:
allInstanceTypeThresholdInfo:
AggregateField: instanceTypeThresholdInfos
AggregateType: 'Fn::ListJoin'
Outputs:
instanceThresholdInfos:
Type: List
Value: '{{ alarmThresholdInfo.allInstanceTypeThresholdInfo }}'