テンプレート名
ACS-ECS-AlarmAccountResourceUsage
テンプレートの説明
Alibaba Cloud アカウント内のリソース使用量を監視し、リソース使用量が指定されたしきい値を超えた場合にアラート通知を送信します。
テンプレートタイプ
自動化
所有者
Alibaba Cloud
入力パラメータ
パラメータ | 説明 | タイプ | 必須 | デフォルト値 | 制限 |
webHookUrl | アラート通知の送信先の Webhook URL です。 | String | はい | ||
regionId | リージョン ID です。 | String | いいえ | {{ ACS::RegionId }} | |
threshold | アラートをトリガーするリソース使用量のしきい値です。 | Number | いいえ | 80 | |
OOSAssumeRole | CloudOps Orchestration Service (OOS) がアシュームする Resource Access Management (RAM) ロールです。 | String | いいえ | OOSServiceRole |
出力パラメータ
なし
テンプレートを実行するために必要な権限ポリシー
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeAccountAttributes"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
参照
詳細については、GitHub の ACS-ECS-AlarmAccountResourceUsage.yml をご参照ください。
テンプレートコンテンツ
FormatVersion: OOS-2019-06-01
Description:
en: Resource usage exceeds threshold alarm notification
zh-cn: the description in Chinese
name-en: ACS-ECS-AlarmAccountResourceUsage
name-zh-cn: the description in Chinese
Parameters:
regionId:
Type: String
Label:
en: RegionId
zh-cn: the description in Chinese
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
threshold:
Label:
en: Threshold
zh-cn: the description in Chinese
Description:
en: example:10 is 10%,50 is 50%
zh-cn: the description in Chinese
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: the description in Chinese '
Label:
en: WebHookUrl
zh-cn: the description in Chinese
Type: String
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: the description in Chinese
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: the description in Chinese
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: the description in Chinese
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: the description in Chinese
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: the description in Chinese
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'
- '{"": ""}'
- '(アカウントの従量課金インスタンス vCPU 使用量が {{ threshold }}% を超えています。 The vCPU usage of the pay-as-you-go instances in your account has exceeded {{threshold}}%. )'
- ''
- 'Fn::If':
- 'Fn::Equals':
- true
- 'Fn::Jq':
- First
- '({{getAccountAttributes.usedSpotInstanceVcpuCount}} / {{getAccountAttributes.maxSpotInstanceVcpuCount}}) >= {{ threshold }}/100'
- '{"": ""}'
- '(アカウントのプリエンプティブルインスタンス vCPU 使用量が {{ threshold }}% を超えています。 The vCPU usage of the preemptible instances in your account has exceeded {{threshold}}%. )'
- ''
- 'Fn::If':
- 'Fn::Equals':
- true
- 'Fn::Jq':
- First
- '({{getAccountAttributes.usedPostpaidYundiskCapacityCloudEfficiency}} / {{getAccountAttributes.maxPostpaidYundiskCapacityCloudEfficiency}}) >= {{ threshold }}/100'
- '{"": ""}'
- '(アカウントの従量課金 Ultra ディスク (データディスクとして使用) の使用量が {{ threshold }}% を超えています。 The usage of pay-as-you-go ultra disks that are used as data disks in your account has exceeded {{threshold}}%. )'
- ''
- 'Fn::If':
- 'Fn::Equals':
- true
- 'Fn::Jq':
- First
- '({{getAccountAttributes.usedPostpaidYundiskCapacityCloudSsd}} / {{getAccountAttributes.maxPostpaidYundiskCapacityCloudSsd}}) >= {{ threshold }}/100'
- '{"": ""}'
- '(アカウントの従量課金 SSD (データディスクとして使用) の使用量が {{ threshold }}% を超えています。 The usage of pay-as-you-go SSDs that are used as data disks in your account has exceeded {{threshold}}%. )'
- ''
- 'Fn::If':
- 'Fn::Equals':
- true
- 'Fn::Jq':
- First
- '({{getAccountAttributes.usedPostpaidYundiskCapacityCloudEssd}} / {{getAccountAttributes.maxPostpaidYundiskCapacityCloudEssd}}) >= {{ threshold }}/100'
- '{"": ""}'
- '(アカウントの従量課金 企業向け SSD (ESSD、データディスクとして使用) の使用量が {{ threshold }}% を超えています。 The usage of pay-as-you-go Enterprise SSDs (ESSDs) that are used as data disks in your account has exceeded {{threshold}}%. )'
- ''
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- regionId
- threshold
- webHookUrl
Label:
default:
zh-cn: the description in Chinese
en: Configure Parameters
- Parameters:
- OOSAssumeRole
Label:
default:
zh-cn: the description in Chinese
en: Control Options