-
Notifications
You must be signed in to change notification settings - Fork 17
/
ACS-ECS-AlarmAccountResourceUsage.yml
219 lines (219 loc) · 9.59 KB
/
ACS-ECS-AlarmAccountResourceUsage.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
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
FormatVersion: OOS-2019-06-01
Description:
en: Resource usage exceeds threshold alarm notification
zh-cn: 账户资源使用率超出阈值后报警通知
name-en: ACS-ECS-AlarmAccountResourceUsage
name-zh-cn: 账户资源使用率超出阈值后报警
Parameters:
regionId:
Type: String
Label:
en: RegionId
zh-cn: 地域ID
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
threshold:
Label:
en: Threshold
zh-cn: 资源使用率警报的阈值
Description:
en: example:10 is 10%,50 is 50%
zh-cn: 例如:10为10%,50为50%
Type: Number
Default: 80
MinValue: 20
MaxValue: 99
webHookUrl:
Description:
en: 'e.g.https://oapi.dingtalk.com/robot/send?access_token=1234zxcvaksdq31414,acquiring DingTalk webhook please refer to second appendix in https://help.aliyun.com/document_detail/144679.html.'
zh-cn: '形如https://oapi.dingtalk.com/robot/send?access_token=1234zxcvaksdq31414,具体钉钉WebHook获取请参考https://help.aliyun.com/document_detail/144679.html#h2--2-webhook-5。'
Label:
en: WebHookUrl
zh-ch: 钉钉群助手的webhook地址
Type: String
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: OOS扮演的RAM角色
Type: String
Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: timerTrigger
Action: 'ACS::TimerTrigger'
Description:
en: Triggers a task as scheduled by specifying Cron expression
zh-cn: 通过指定Cron表达式按计划触发任务
Properties:
Type: rate
Expression: 30 minutes
EndDate: '2099-12-01T00:00:00Z'
- Name: getAccountAttributes
Action: 'ACS::ExecuteApi'
Description:
en: Query the quotas of ECS resources that you can create in a region
zh-cn: 查询指定地域下能创建的ECS资源配额
Properties:
Service: ECS
API: DescribeAccountAttributes
Parameters:
RegionId: '{{ regionId }}'
Outputs:
usedPostpaidInstanceVcpuCount:
ValueSelector: '.AccountAttributeItems.AccountAttributeItem[13].AttributeValues.ValueItem[].Value | tonumber'
Type: Number
usedSpotInstanceVcpuCount:
ValueSelector: '.AccountAttributeItems.AccountAttributeItem[14].AttributeValues.ValueItem[].Value | tonumber'
Type: Number
usedPostpaidYundiskCapacityCloudEfficiency:
ValueSelector: '.AccountAttributeItems.AccountAttributeItem[16].AttributeValues.ValueItem[0].Value | tonumber'
Type: Number
usedPostpaidYundiskCapacityCloudSsd:
ValueSelector: '.AccountAttributeItems.AccountAttributeItem[16].AttributeValues.ValueItem[1].Value | tonumber'
Type: Number
usedPostpaidYundiskCapacityCloudEssd:
ValueSelector: '.AccountAttributeItems.AccountAttributeItem[16].AttributeValues.ValueItem[2].Value | tonumber'
Type: Number
maxPostpaidInstanceVcpuCount:
ValueSelector: '.AccountAttributeItems.AccountAttributeItem[6].AttributeValues.ValueItem[].Value | tonumber'
Type: Number
maxSpotInstanceVcpuCount:
ValueSelector: '.AccountAttributeItems.AccountAttributeItem[7].AttributeValues.ValueItem[].Value | tonumber'
Type: Number
maxPostpaidYundiskCapacityCloudEfficiency:
ValueSelector: '.AccountAttributeItems.AccountAttributeItem[15].AttributeValues.ValueItem[0].Value | tonumber'
Type: Number
maxPostpaidYundiskCapacityCloudSsd:
ValueSelector: '.AccountAttributeItems.AccountAttributeItem[15].AttributeValues.ValueItem[1].Value | tonumber'
Type: Number
maxPostpaidYundiskCapacityCloudEssd:
ValueSelector: '.AccountAttributeItems.AccountAttributeItem[15].AttributeValues.ValueItem[2].Value | tonumber'
Type: Number
- Name: checkResourceUsage
Action: 'ACS::Choice'
Description:
en: Choose the notification task by usage
zh-cn: 通过使用率选择通知任务
Properties:
DefaultTask: 'ACS::END'
Choices:
- When:
'Fn::Equals':
- true
- 'Fn::Jq':
- First
- '({{getAccountAttributes.usedPostpaidInstanceVcpuCount}} / {{getAccountAttributes.maxPostpaidInstanceVcpuCount}}) >= {{ threshold }}/100'
- '{"": ""}'
NextTask: alarmNotify
- When:
'Fn::Equals':
- true
- 'Fn::Jq':
- First
- '({{getAccountAttributes.usedSpotInstanceVcpuCount}} / {{getAccountAttributes.maxSpotInstanceVcpuCount}}) >= {{ threshold }}/100'
- '{"": ""}'
NextTask: alarmNotify
- When:
'Fn::Equals':
- true
- 'Fn::Jq':
- First
- '({{getAccountAttributes.usedPostpaidYundiskCapacityCloudEfficiency}} / {{getAccountAttributes.maxPostpaidYundiskCapacityCloudEfficiency}}) >= {{ threshold }}/100'
- '{"": ""}'
NextTask: alarmNotify
- When:
'Fn::Equals':
- true
- 'Fn::Jq':
- First
- '({{getAccountAttributes.usedPostpaidYundiskCapacityCloudSsd}} / {{getAccountAttributes.maxPostpaidYundiskCapacityCloudSsd}}) >= {{ threshold }}/100'
- '{"": ""}'
NextTask: alarmNotify
- When:
'Fn::Equals':
- true
- 'Fn::Jq':
- First
- '({{getAccountAttributes.usedPostpaidYundiskCapacityCloudEssd}} / {{getAccountAttributes.maxPostpaidYundiskCapacityCloudEssd}}) >= {{ threshold }}/100'
- '{"": ""}'
NextTask: alarmNotify
- Name: alarmNotify
Action: 'ACS::Notify'
OnSuccess: 'ACS::END'
Description:
en: Resource usage exceeds threshold alarm notification
zh-cn: 资源使用率超出阈值报警通知
Properties:
NotifyType: WebHook
WebHook:
URI: '{{ webHookUrl }}'
Headers:
Content-Type: application/json
Content:
msgtype: text
text:
content:
'Fn::Join':
- '|-|-|'
- - 'Fn::If':
- 'Fn::Equals':
- true
- 'Fn::Jq':
- First
- '({{getAccountAttributes.usedPostpaidInstanceVcpuCount}} / {{getAccountAttributes.maxPostpaidInstanceVcpuCount}}) >= {{ threshold }}/100'
- '{"": ""}'
- '(The PostpaidInstanceVcpuCount usage under your account exceeds {{ threshold }}%. 您账户的 按量付费实例的VCPU核数 使用率已超过{{threshold}}%。)'
- ''
- 'Fn::If':
- 'Fn::Equals':
- true
- 'Fn::Jq':
- First
- '({{getAccountAttributes.usedSpotInstanceVcpuCount}} / {{getAccountAttributes.maxSpotInstanceVcpuCount}}) >= {{ threshold }}/100'
- '{"": ""}'
- '(The SpotInstanceVcpuCount usage under your account exceeds {{ threshold }}%. 您账户的 抢占式实例VCPU核数 使用率已超过{{threshold}}%。)'
- ''
- 'Fn::If':
- 'Fn::Equals':
- true
- 'Fn::Jq':
- First
- '({{getAccountAttributes.usedPostpaidYundiskCapacityCloudEfficiency}} / {{getAccountAttributes.maxPostpaidYundiskCapacityCloudEfficiency}}) >= {{ threshold }}/100'
- '{"": ""}'
- '(The PostpaidYundiskCapacityCloudEfficiency usage under your account exceeds {{ threshold }}%. 您账户的 用作数据盘的按量付费Cloud_efficiency云盘容量 使用率已超过{{threshold}}%。)'
- ''
- 'Fn::If':
- 'Fn::Equals':
- true
- 'Fn::Jq':
- First
- '({{getAccountAttributes.usedPostpaidYundiskCapacityCloudSsd}} / {{getAccountAttributes.maxPostpaidYundiskCapacityCloudSsd}}) >= {{ threshold }}/100'
- '{"": ""}'
- '(The PostpaidYundiskCapacityCloudSsd usage under your account exceeds {{ threshold }}%. 您账户的 用作数据盘的按量付费cloud_ssd云盘容量 使用率已超过{{threshold}}%。)'
- ''
- 'Fn::If':
- 'Fn::Equals':
- true
- 'Fn::Jq':
- First
- '({{getAccountAttributes.usedPostpaidYundiskCapacityCloudEssd}} / {{getAccountAttributes.maxPostpaidYundiskCapacityCloudEssd}}) >= {{ threshold }}/100'
- '{"": ""}'
- '(The PostpaidYundiskCapacityCloudEssd usage under your account exceeds {{ threshold }}%. 您账户的 用作数据盘的按量付费cloud_essd云盘容量 使用率已超过{{threshold}}%。)'
- ''
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- regionId
- threshold
- webHookUrl
Label:
default:
zh-cn: 配置参数
en: Configure Parameters
- Parameters:
- OOSAssumeRole
Label:
default:
zh-cn: 高级选项
en: Control Options