模板名稱
ACS-ECS-AlarmAccountResourceUsage 賬戶資源使用率超出閾值後警示
模板描述
賬戶資源使用率超出閾值後警示通知
模板類型
自動化
所有者
Alibaba Cloud
輸入參數
參數名稱 | 描述 | 類型 | 是否必填 | 預設值 | 約束 |
webHookUrl | None | String | 是 | ||
regionId | 地區ID | String | 否 | {{ ACS::RegionId }} | |
threshold | 資源使用率警報的閾值 | Number | 否 | 80 | |
OOSAssumeRole | OOS扮演的RAM角色 | String | 否 | OOSServiceRole |
輸出參數
無
執行此模板需要的權限原則
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeAccountAttributes"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
詳情
ACS-ECS-AlarmAccountResourceUsage詳情
模板內容
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,具體DingTalkWebHook擷取請參考https://help.aliyun.com/document_detail/144679.html#h2--2-webhook-5。'
Label:
en: WebHookUrl
zh-ch: DingTalk群助手的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