すべてのプロダクト
Search
ドキュメントセンター

CloudOps Orchestration Service:ACS-ECS-AlarmWhenDiscountAndPriceExceedsThresholdInMultiZoneAndInstanceType

最終更新日:Jun 23, 2026

テンプレート名

ACS-ECS-AlarmWhenDiscountAndPriceExceedsThresholdInMultiZoneAndInstanceType は、複数のゾーンにわたる指定された ECS インスタンスタイプの割引またはスポット価格がしきい値を超えた場合にアラートを送信します。

今すぐ実行

テンプレートの説明

複数のゾーンにわたる指定された ECS インスタンスタイプの割引またはスポット価格がしきい値を超えた場合にアラートを送信します。

テンプレートタイプ

自動化

所有者

Alibaba Cloud

入力パラメータ

パラメータ名

説明

タイプ

必須

デフォルト値

制約

zoneId

ゾーン ID

List

はい

instanceType

インスタンスタイプ

List

はい

threshold

価格または割引のしきい値。割引の場合、この値は元の価格に対するパーセンテージを表します。たとえば、10 は元の価格の 10% (90% の割引) を意味します。価格の場合は、価格のしきい値を直接入力します。

Number

はい

webhook

通知を受信するための DingTalk Webhook URL。例: https://oapi.dingtalk.com/robot/send?access_token=...

String

はい

region

リージョン ID。

String

いいえ

{{ ACS::RegionId }}

taskType

監視ジョブのタイプ。有効な値: Discount (割引を監視) または Price (価格を監視)。

String

いいえ

Discount

rateControl

同時実行レート。

Json

いいえ

{'Mode': 'Concurrency', 'MaxErrors': 100, 'Concurrency': 10}

OOSAssumeRole

OOS が引き受ける RAM ロール。

String

いいえ

OOSServiceRole

出力パラメータ

パラメータ名

説明

タイプ

allThresholdInfo

Json

実行に必要なアクセスポリシー

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:DescribeAvailableResource",
                "ecs:DescribeSpotPriceHistory"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

詳細

ACS-ECS-AlarmWhenDiscountAndPriceExceedsThresholdInMultiZoneAndInstanceType

テンプレートの内容

FormatVersion: OOS-2019-06-01
Description:
  en: Sends an alert when the discount or spot price for multiple instance types in multiple zones exceeds a threshold.
  zh-cn: Sends an alert when the discount or spot price for multiple instance types in multiple zones exceeds a threshold.
  name-en: ACS-ECS-AlarmWhenDiscountAndPriceExceedsThresholdInMultiZoneAndInstanceType
  name-zh-cn: Monitor and alert when discount and spot price for multiple instance types in multiple zones exceed a threshold.
  categories:
    - instance_manage
Parameters:
  region:
    Type: String
    Label:
      en: Region ID
      zh-cn: Region ID
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  zoneId:
    Description:
      en: The zone ID.
      zh-cn: The zone ID.
    Label:
      en: Zone
      zh-cn: Zone
    Type: List
    AssociationProperty: ALIYUN::ECS::Instance::ZoneId
    AssociationPropertyMetadata:
      RegionId: region
      AutoChangeType: false
  instanceType:
    Description:
      en: The instance type.
      zh-cn: The instance type.
    Label:
      en: Instance type
      zh-cn: Instance type
    Type: List
    AssociationProperty: 'ALIYUN::ECS::Instance::InstanceType'
    AssociationPropertyMetadata:
      Multiple: true
      RegionId: region
      ZoneIds: '${zoneId}'
  taskType:
    Description:
      en: 'The type of monitoring job. Valid values: Discount (monitors the discount) or Price (monitors the price).'
      zh-cn: 'The type of monitoring job. Valid values: Discount (monitors the discount) or Price (monitors the price).'
    Label:
      en: Monitoring job type
      zh-cn: Monitoring job type
    Type: String
    Default: Discount
    AllowedValues:
      - Discount
      - Price
  threshold:
    Description:
      en: 'The price or discount threshold. For discounts, the value represents a percentage of the original price. For example, 10 means 10% of the original price (a 90% discount). For prices, enter the price threshold directly.'
      zh-cn: 'The price or discount threshold. For discounts, the value represents a percentage of the original price. For example, 10 means 10% of the original price (a 90% discount). For prices, enter the price threshold directly.'
    Label:
      en: Price/discount threshold
      zh-cn: Price/discount threshold
    Type: Number
  webhook:
    Label:
      en: DingTalk webhook URL
      zh-cn: 'DingTalk webhook URL'
    Description:
      en: 'Example: https://oapi.dingtalk.com/robot/send?access_token=bac51db2e39418ec6c2dbb27fd111bc7xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.'
      zh-cn: 'Example: https://oapi.dingtalk.com/robot/send?access_token=bac51db2e39418ec6c2dbb27fd111bc7xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.'
    Type: String
  rateControl:
    Label:
      en: Concurrency rate
      zh-cn: Concurrency rate
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 100
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: RAM role for OOS
      zh-cn: RAM role for OOS
    Type: String
    Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: alarmThresholdInfo
    Action: 'ACS::ECS::AlarmSpotPriceByDiscountThresholdWithMultiTypes'
    Description:
      en: Sends an alert when the discount or spot price for multiple instance types in multiple zones exceeds a threshold.
      zh-cn: Sends an alert when the discount or spot price for multiple instance types in multiple zones exceeds a threshold.
    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: whetherToNotifyWebhook
    Action: 'ACS::Choice'
    Description:
      en: Checks if an alert notification is required.
      zh-cn: Checks if an alert notification is required.
    Properties:
      DefaultTask: alarmNotify
      Choices:
        - When:
            'Fn::Equals':
              - []
              - 'Fn::MergeList': '{{ alarmThresholdInfo.allThresholdInfos }}'
          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 }}
                    - |
                      | Instance type |  Zone|Current price|Discount %|
                    - |
                      |:----|----:|:----:|:----|
                    - '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':
            - |
              ##### Alarm threshold: {{ threshold }}
            - |
              | Instance type |  Zone|Current price|Discount %|
            - |
              |:----|----:|:----:|:----|
            - '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: Configure Parameters
            en: Configure Parameters
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
            zh-cn: Advanced Options
            en: Advanced Options