テンプレート名
複数ゾーンおよびインスタンスタイプで割引と価格がしきい値を超えた場合のアラーム
テンプレートの説明
指定されたゾーンの指定されたインスタンスタイプの価格または割引を監視し、価格または割引が指定されたしきい値を超えた場合にアラート通知を送信します。
テンプレートタイプ
自動化
所有者
Alibaba Cloud
入力パラメーター
パラメーター | 説明 | タイプ | 必須 | デフォルト値 | 制限 |
zoneId | ゾーン ID。 | リスト | はい | ||
instanceType | インスタンスタイプ。 | リスト | はい | ||
threshold | 割引またはスポット価格のしきい値。 | 数値 | はい | ||
webhook | DingTalk チャットボットの Webhook URL。 | 文字列 | はい | ||
region | リージョン ID。 | 文字列 | いいえ | {{ ACS::RegionId }} | |
taskType | 監視ジョブのタイプ。 | 文字列 | いいえ | 割引 | |
rateControl | レート制御設定。 | JSON | いいえ | {'Mode': 'Concurrency', 'MaxErrors': 100, 'Concurrency': 10} | |
OOSAssumeRole | CloudOps Orchestration Service (OOS) によって引き受けられる Resource Access Management (RAM) ロール。 | 文字列 | いいえ | OOSServiceRole |
出力パラメーター
パラメーター | 説明 | タイプ |
allThresholdInfo | JSON |
テンプレートを実行するために必要な権限ポリシー
{
"Version": "1",
"Statement": [
{
"Action": [
"ecs:DescribeAvailableResource",
"ecs:DescribeSpotPriceHistory"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
参照
詳細については、GitHub の ACS-ECS-AlarmWhenDiscountAndPriceExceedsThresholdInMultiZoneAndInstanceType.yml をご参照ください。
テンプレートコンテンツ
FormatVersion: OOS-2019-06-01
Description:
en: Alarm when monitoring the discount and spot price of multi-instance types in multi-availability zone exceeding the threshold
zh-cn: the description in Chinese
name-en: ACS-ECS-AlarmWhenDiscountAndPriceExceedsThresholdInMultiZoneAndInstanceType
name-zh-cn: the description in Chinese
categories:
- instance_manage
Parameters:
region:
Type: String
Label:
en: RegionId
zh-cn: the description in Chinese
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
zoneId:
Description:
en: The zone id
zh-cn: the description in Chinese
Label:
en: ZoneId
zh-cn: the description in Chinese
Type: List
AssociationProperty: ALIYUN::ECS::Instance::ZoneId
AssociationPropertyMetadata:
RegionId: region
AutoChangeType: false
instanceType:
Description:
en: The instance type
zh-cn: the description in Chinese
Label:
en: InstanceType
zh-cn: the description in Chinese
Type: List
AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
AssociationPropertyMetadata:
Multiple: true
RegionId: region
ZoneIds: '${zoneId}'
taskType:
Description:
en: The monitoring threshold task type (Discount: Monitor discount, Price: monitor price)
zh-cn: the description in Chinese
Label:
en: TaskType
zh-cn: the description in Chinese
Type: String
Default: Discount
AllowedValues:
- Discount
- Price
threshold:
Description:
en: 'The discount/price threshold(example:10 is 1% off,50 is 50% off,Or directly enter the price threshold).'
zh-cn: the description in Chinese
Label:
en: Threshold
zh-cn: the description in Chinese
Type: Number
webhook:
Label:
en: Webhook
zh-cn: the description in Chinese
Description:
en: '(example:https://oapi.dingtalk.com/robot/send?access_token=bac51db2e39418ec6c2dbb27fd111bc7xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx).'
zh-cn: the description in Chinese '
Type: String
rateControl:
Label:
en: RateControl
zh-cn: the description in Chinese
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 100
Concurrency: 10
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: the description in Chinese
Type: String
Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: alarmThresholdInfo
Action: 'ACS::ECS::AlarmSpotPriceByDiscountThresholdWithMultiTypes'
Description:
en: Alarm when monitoring the discount and spot price of multi-instance types under multi-availability zone exceeding the threshold
zh-cn: the description in Chinese
Properties:
regionId: '{{ region }}'
zoneId: '{{ ACS::TaskLoopItem }}'
instanceTypes: '{{ instanceType }}'
threshold: '{{ threshold }}'
taskType: '{{ taskType }}'
Outputs:
zoneInstanceTypeThresholdInfo:
Type: Json
ValueSelector: instanceTypeThresholdInfo
Loop:
Items: '{{ zoneId }}'
RateControl: '{{ rateControl }}'
Outputs:
allThresholdInfos:
AggregateField: zoneInstanceTypeThresholdInfo
AggregateType: 'Fn::ListJoin'
- Name: wetherNodifyWebhook
Action: 'ACS::Choice'
Description:
en: Detect if an alarm notification is required
zh-cn: the description in Chinese
Properties:
DefaultTask: alarmNotify
Choices:
- When:
'Fn::Equals':
- []
- 'Fn::MergeList': '{{ alarmThresholdInfo.allThresholdInfos }}'
NextTask: 'ACS::END'
- Name: alarmNotify
Action: 'ACS::Notify'
Description:
en: Instance discount / spot price exceeds threshold alarm notification
zh-cn: the description in Chinese
Properties:
NotifyType: WebHook
WebHook:
URI: '{{ webhook }}'
Headers:
Content-Type: application/json
Content:
msgtype: markdown
markdown:
title: 監視結果
text:
'Fn::Join':
- ''
- 'Fn::ListJoin':
- |
##### アラートしきい値 (アラームしきい値):{{ threshold }}
- |
| インスタンスタイプ |  ゾーン|現在の価格|割引|
- |
|:----|----:|:----:|:----|
- 'Fn::Jq':
- First
- '.[]|split(", ") | join("") |split("\n,")| join("")| split("\n,|")|join("") |split("||")|join("|")'
- 'Fn::Jq':
- All
- '.[1]=""|join("|")'
- 'Fn::Jq':
- All
- '.[1]=""| .[1]=.[0] | .[0]="" | join("|")'
- 'Fn::Jq':
- All
- map(.) | join("\n|")
- 'Fn::Jq':
- All
- '.[] | map(.[] | tostring)| join(" |")'
- 'Fn::Jq':
- All
- 'map(.| .threshold=.threshold+" |\n," )'
- 'Fn::MergeList': '{{ alarmThresholdInfo.allThresholdInfos }}'
Outputs:
allThresholdInfo:
Type: Json
Value:
'Fn::Join':
- ''
- 'Fn::ListJoin':
- |
##### アラートしきい値 (アラームしきい値):{{ threshold }}
- |
| インスタンスタイプ |  ゾーン|現在の価格|割引|
- |
|:----|----:|:----:|:----|
- 'Fn::Jq':
- First
- '.[]|split(", ") | join("") |split("\n,")| join("")| split("\n,|")|join("") |split("||")|join("|")'
- 'Fn::Jq':
- All
- '.[1]=""|join("|")'
- 'Fn::Jq':
- All
- '.[1]=""| .[1]=.[0] | .[0]="" | join("|")'
- 'Fn::Jq':
- All
- map(.) | join("\n|")
- 'Fn::Jq':
- All
- '.[] | map(.[] | tostring)| join(" |")'
- 'Fn::Jq':
- All
- 'map(.| .threshold=.threshold+" |\n," )'
- 'Fn::MergeList': '{{ alarmThresholdInfo.allThresholdInfos }}'
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- region
- zoneId
- instanceType
- taskType
- threshold
- webhook
Label:
default:
zh-cn: the description in Chinese
en: Configure Parameters
- Parameters:
- rateControl
- OOSAssumeRole
Label:
default:
zh-cn: the description in Chinese
en: Control Options