Template name
ACS-ECS-AlarmDiscountOrPriceInScalingGroupExistingInstanceTypes - Sends an alert when the price or discount of an existing instance type in a scaling group exceeds a threshold.
Template description
Monitors the discounts and prices of existing spot instances in a scaling group and sends an alert if a price or discount exceeds the specified threshold.
Template type
Automation
Owner
Alibaba Cloud
Input parameters
|
Parameter name |
Description |
Type |
Required |
Default value |
Constraints |
|
scalingGroupId |
The ID of the scaling group. |
List |
Yes |
||
|
threshold |
The price or discount threshold. |
Number |
Yes |
||
|
webhook |
The webhook URL of the DingTalk chatbot that receives messages. |
String |
Yes |
||
|
region |
The region ID. |
String |
No |
{{ ACS::RegionId }} |
|
|
taskType |
The type of the monitoring task. |
String |
No |
Discount |
|
|
rateControl |
The concurrency rate for task execution. |
Json |
No |
{‘Mode’: ‘Concurrency’, ‘MaxErrors’: 100, ‘Concurrency’: 10} |
|
|
OOSAssumeRole |
The RAM role that OOS assumes. |
String |
No |
OOSServiceRole |
Response parameters
|
Parameter name |
Description |
Type |
|
allThresholdInfo |
List |
Access policy required for this template
{
"Version": "1",
"Statement": [
{
"Action": [
"ess:DescribeScalingGroups",
"ess:DescribeScalingInstances"
],
"Resource": "*",
"Effect": "Allow"
},
{
"Action": [
"ecs:DescribeInstances",
"ecs:DescribeSpotPriceHistory"
],
"Resource": "*",
"Effect": "Allow"
}
]
}
Details
ACS-ECS-AlarmDiscountOrPriceInScalingGroupExistingInstanceTypes details
Template content
FormatVersion: OOS-2019-06-01
Description:
en: 'Monitors the discounts and prices of existing spot instances in the scaling group. Sends an alert notification if the values exceed the specified threshold.'
zh-cn: 'Monitors the discounts and prices of existing spot instances in the scaling group. Sends an alert notification if the actual value exceeds the threshold.'
name-en: ACS-ECS-AlarmDiscountOrPriceInScalingGroupExistingInstanceTypes
name-zh-cn: 'Sends an alert when the price or discount of existing instance types in a scaling group exceeds a threshold.'
Parameters:
region:
Type: String
Label:
en: RegionId
zh-cn: Region ID
AssociationProperty: RegionId
Default: '{{ ACS::RegionId }}'
scalingGroupId:
Description:
en: ScalingGroupId
zh-cn: The ID of the Auto Scaling group.
Label:
en: scalingGroupId
zh-cn: Scaling Group ID
Type: List
taskType:
Description:
en: 'The type of monitoring task. Valid values: Discount (monitors discount) and Price (monitors price).'
zh-cn: 'The type of monitoring task. Valid values: Discount (monitors discount) and Price (monitors price).'
Label:
en: TaskType
zh-cn: Monitoring Task Type
Type: String
Default: Discount
AllowedValues:
- Discount
- Price
threshold:
Description:
en: 'The price or discount threshold. For discounts, the value represents the percentage of the pay-as-you-go price. For example, 10 means the spot price is 10% of the pay-as-you-go price. For prices, enter the price threshold directly.'
zh-cn: 'The price or discount threshold. For discounts, the value represents the percentage of the pay-as-you-go price. For example, 10 means the spot price is 10% of the pay-as-you-go price. For prices, enter the price threshold directly.'
Label:
en: Threshold
zh-cn: Price/Discount Threshold
Type: Number
webhook:
Description:
en: 'example:https://oapi.dingtalk.com/robot/send?access_token=bac51db2e39418ec6c2dbb27fd111bc7xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.'
zh-cn: 'Example: https://oapi.dingtalk.com/robot/send?access_token=bac51db2e39418ec6c2dbb27fd111bc7xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.'
Label:
en: Webhook
zh-cn: 'The webhook URL for DingTalk notifications.'
Type: String
rateControl:
Label:
en: RateControl
zh-cn: Task Execution Concurrency Rate
Type: Json
AssociationProperty: RateControl
Default:
Mode: Concurrency
MaxErrors: 100
Concurrency: 10
OOSAssumeRole:
Label:
en: OOSAssumeRole
zh-cn: The RAM role that OOS assumes.
Type: String
Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
- Name: describeScalingGroups
Action: 'ACS::ExecuteAPI'
Description:
en: Queries the scaling groups.
zh-cn: Queries the Auto Scaling groups.
Properties:
Service: ESS
API: DescribeScalingGroups
Parameters:
RegionId: '{{ region }}'
ScalingGroupId1: '{{ ACS::TaskLoopItem }}'
Outputs:
scalingGroupInfo:
Type: String
ValueSelector: '.ScalingGroups.ScalingGroup[].ScalingGroupId'
Loop:
Items: '{{ scalingGroupId }}'
RateControl: '{{ rateControl }}'
Outputs:
scalingGroupInfos:
AggregateType: 'Fn::ListJoin'
AggregateField: scalingGroupInfo
- Name: wetherOutPutPriceInfo
Action: 'ACS::Choice'
Description:
en: Checks whether the scaling group exists.
zh-cn: Checks whether the scaling group exists.
Properties:
DefaultTask: scalingGroupMonitorInfos
Choices:
- When:
'Fn::Equals':
- []
- 'Fn::MergeList': '{{ describeScalingGroups.scalingGroupInfos }}'
NextTask: 'ACS::END'
- Name: scalingGroupMonitorInfos
Action: 'ACS::ECS::AlarmSpotPriceOrDiscountBySingleScalingGroup'
Description:
en: Monitors the discount or price of the instance types in the scaling group.
zh-cn: Monitors the discount or price of the instance types in the Auto Scaling group.
Properties:
regionId: '{{region}}'
threshold: '{{ threshold }}'
taskType: '{{ taskType }}'
scalingGroupId: '{{ ACS::TaskLoopItem }}'
Outputs:
monitorInfo:
Type: String
ValueSelector: singleMonitorInfo
Loop:
Items: '{{ scalingGroupId }}'
RateControl: '{{ rateControl }}'
Outputs:
allMonitorInfo:
AggregateField: monitorInfo
AggregateType: 'Fn::ListJoin'
- Name: wetherNodifyWebhook
Action: 'ACS::Choice'
Description:
en: Checks whether an alert notification is required.
zh-cn: Checks whether an alert notification needs to be sent.
Properties:
DefaultTask: alarmNotify
Choices:
- When:
'Fn::Equals':
- []
- 'Fn::MergeList':
- '{{ scalingGroupMonitorInfos.allMonitorInfo }}'
NextTask: 'ACS::END'
- Name: alarmNotify
Action: 'ACS::Notify'
Description:
en: Sends an alert notification if the instance discount or spot price exceeds the threshold.
zh-cn: Sends an alert notification if the instance discount or spot price exceeds the threshold.
Properties:
NotifyType: WebHook
WebHook:
URI: '{{ webhook }}'
Headers:
Content-Type: application/json
Content:
msgtype: markdown
markdown:
title: Monitoring Result
text:
'Fn::Join':
- ''
- 'Fn::ListJoin':
- |
### Alarm threshold (%): {{ threshold }}
- 'Fn::Jq':
- First
- . | join("\n\n")
- 'Fn::MergeList':
- '{{ scalingGroupMonitorInfos.allMonitorInfo }}'
Outputs:
allThresholdInfo:
Type: List
Value:
'Fn::Join':
- ''
- 'Fn::ListJoin':
- |
### Alarm threshold (%): {{ threshold }}
- 'Fn::Jq':
- First
- . | join("\n\n")
- 'Fn::MergeList':
- '{{ scalingGroupMonitorInfos.allMonitorInfo }}'
Metadata:
ALIYUN::OOS::Interface:
ParameterGroups:
- Parameters:
- region
- scalingGroupId
- taskType
- threshold
- webhook
Label:
default:
zh-cn: Configure Parameters
en: Configure Parameters
- Parameters:
- rateControl
- OOSAssumeRole
Label:
default:
zh-cn: Advanced Options
en: Advanced Options