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

CloudOps Orchestration Service:ACS-ECS-AlarmWhenDiscountOrSpotPriceExceedsThresholdByScalingGroup

最終更新日:Jun 23, 2026

テンプレート名

スケーリンググループ内のスポットインスタンスの価格または割引が、指定したしきい値を超えた場合にアラート通知を送信します。

[Execute now]

テンプレートの説明

スケーリンググループ内のスポットインスタンスの価格と割引を監視し、値が指定したしきい値を超えた場合にアラート通知を送信します。

テンプレートタイプ

オートメーション

所有者

Alibaba Cloud

入力パラメータ

パラメータ名

説明

タイプ

必須

デフォルト値

制約

scalingGroupId

スケーリンググループの ID です。

List

必須

threshold

価格または割引のしきい値です。たとえば、割引を監視する場合、値 10 は従量課金価格の 10% (90% の割引) を意味し、50 は従量課金価格の 50% を意味します。しきい値として直接価格値を入力することもできます。

Number

必須

webhook

アラートメッセージを受信するための DingTalk webhook URL です。

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

List

実行に必要な権限ポリシー

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ess:DescribeScalingConfigurations",
                "ess:DescribeScalingGroups"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "ecs:DescribeSpotPriceHistory",
                "ecs:DescribeVSwitches"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

詳細

詳細については、「ACS-ECS-AlarmWhenDiscountOrSpotPriceExceedsThresholdByScalingGroup」をご参照ください。

テンプレートの内容

FormatVersion: OOS-2019-06-01
Description:
  en: スケーリンググループ内のスポットインスタンスの価格と割引を監視し、値が指定したしきい値を超えた場合にアラート通知を送信します。
  zh-cn: Monitors the price and discount of spot instances in a scaling group and sends an alert notification if the value exceeds a specified threshold.
  name-en: ACS-ECS-AlarmWhenDiscountOrSpotPriceExceedsThresholdByScalingGroup
  name-zh-cn: Sends an alert when the price or discount of spot instances in a scaling group exceeds a threshold.
Parameters:
  region:
    Type: String
    Label:
      en: リージョン ID
      zh-cn: Region ID
    Description:
      en: リージョン。
      zh-cn: The region.
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  scalingGroupId:
    Description:
      en: スケーリンググループの ID。
      zh-cn: The ID of the Auto Scaling group.
    Label:
      en: スケーリンググループ ID
      zh-cn: Scaling Group ID
    Type: List
  taskType:
    Description:
      en: 監視ジョブのタイプ。有効な値は Discount (割引を監視) と Price (価格を監視) です。
      zh-cn: The type of the monitoring job. Valid values are Discount (monitors discount) and Price (monitors price).
    Label:
      en: 監視ジョブタイプ
      zh-cn: Monitoring Job Type
    Type: String
    Default: Discount
    AllowedValues:
      - Discount
      - Price
  threshold:
    Description:
      en: 価格または割引のしきい値。たとえば、割引を監視する場合、値 10 は従量課金価格の 10% (90% の割引) を意味し、50 は従量課金価格の 50% を意味します。しきい値として直接価格値を入力することもできます。
      zh-cn: The price or discount threshold. For example, if you monitor discounts, a value of 10 means 10% of the pay-as-you-go price (a 90% discount), and 50 means 50% of the pay-as-you-go price. You can also enter a direct price value for the threshold.
    Label:
      en: 価格/割引のしきい値
      zh-cn: Price/Discount Threshold
    Type: Number
  webhook:
    Label:
      en: DingTalk Webhook URL
      zh-cn: DingTalk Webhook URL
    Description:
      en: '例: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: タスク実行の同時実行数
      zh-cn: Task Execution Concurrency
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 100
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: OOS が引き受ける RAM ロール
      zh-cn: RAM Role for OOS to Assume
    Type: String
    Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: describeScalingGroups
    Action: 'ACS::ExecuteAPI'
    Description:
      en: スケーリンググループをクエリします。
      zh-cn: Queries Auto Scaling groups.
    Properties:
      Service: ESS
      API: DescribeScalingGroups
      Parameters:
        RegionId: '{{ region }}'
        ScalingGroupId1: '{{ ACS::TaskLoopItem }}'
    Outputs:
      scalingGroupInfo:
        Type: Json
        ValueSelector: '.ScalingGroups.ScalingGroup[] | {"scalingConfigurationId":.ActiveScalingConfigurationId, "scalingGroupId":.ScalingGroupId, "vSwitchIds": .VSwitchIds.VSwitchId}'
    Loop:
      Items: '{{ scalingGroupId }}'
      RateControl: '{{ rateControl }}'
      Outputs:
        scalingGroupInfos:
          AggregateType: 'Fn::ListJoin'
          AggregateField: scalingGroupInfo
  - Name: describeScalingConfigurations
    Action: 'ACS::ExecuteAPI'
    Description:
      en: 既存のスケーリング設定をクエリします。
      zh-cn: Queries existing scaling configurations.
    Properties:
      Service: ESS
      API: DescribeScalingConfigurations
      Parameters:
        RegionId: '{{ region }}'
        ScalingConfigurationId1:
          'Fn::Jq':
            - First
            - .scalingConfigurationId
            - '{{ ACS::TaskLoopItem }}'
    Outputs:
      scalingConfigurationInfo:
        Type: Json
        ValueSelector: '.ScalingConfigurations.ScalingConfiguration[] | {"instanceTypes":.InstanceTypes.InstanceType, "scalingConfigurationId":.ScalingConfigurationId}'
    Loop:
      Items: '{{ describeScalingGroups.scalingGroupInfos }}'
      RateControl: '{{ rateControl }}'
      Outputs:
        scalingConfigurationInfos:
          AggregateType: 'Fn::ListJoin'
          AggregateField: scalingConfigurationInfo
  - Name: describeVSwitches
    Action: 'ACS::ExecuteAPI'
    Description:
      en: 既存の vSwitch をクエリします。
      zh-cn: Queries existing vSwitches.
    Properties:
      Service: ECS
      API: DescribeVSwitches
      Parameters:
        RegionId: '{{ region }}'
        VSwitchId: '{{ ACS::TaskLoopItem }}'
    Outputs:
      zoneInfo:
        Type: Json
        ValueSelector: '.VSwitches.VSwitch[] | {"vSwitchId":.VSwitchId, "zoneId":.ZoneId}'
    Loop:
      Items:
        'Fn::MergeList':
          'Fn::Jq':
            - All
            - '.[].vSwitchIds'
            - '{{ describeScalingGroups.scalingGroupInfos }}'
      RateControl: '{{ rateControl }}'
      Outputs:
        zoneInfos:
          AggregateType: 'Fn::ListJoin'
          AggregateField: zoneInfo
  - Name: wetherOutPutPriceInfo
    Action: 'ACS::Choice'
    Description:
      en: 価格をクエリするかどうかを確認します。
      zh-cn: Checks whether to query prices.
    Properties:
      DefaultTask: instanceThresholdInfo
      Choices:
        - When:
            'Fn::Equals':
              - []
              - 'Fn::MergeList': '{{ describeScalingGroups.scalingGroupInfos }}'
          NextTask: 'ACS::END'
  - Name: instanceThresholdInfo
    Action: 'ACS::ECS::AlarmSpotPriceOrDiscountThresholdByScalingGroup'
    Description:
      en: スケーリンググループの割引または価格を監視します。
      zh-cn: Monitors the discount or price for the Auto Scaling group.
    Properties:
      regionId: '{{region}}'
      threshold: '{{ threshold }}'
      taskType: '{{ taskType }}'
      vSwitchId:
        'Fn::Jq':
          - First
          - .vSwitchId
          - '{{ ACS::TaskLoopItem }}'
      scalingConfigurationId:
        'Fn::Jq':
          - First
          - .scalingConfigurationId
          - '{{ ACS::TaskLoopItem }}'
      configurationInfos: '{{ describeScalingConfigurations.scalingConfigurationInfos }}'
      scalingGroupId:
        'Fn::Jq':
          - First
          - .scalingGroupId
          - '{{ ACS::TaskLoopItem }}'
      zoneIds: '{{ describeVSwitches.zoneInfos }}'
    Outputs:
      thresholdInfo:
        Type: List
        ValueSelector: instanceThresholdInfos
    Loop:
      Items:
        'Fn::Jq':
          - All
          - '.[] | {scalingConfigurationId, scalingGroupId, "vSwitchId":.vSwitchIds[]}'
          - 'Fn::MergeList':
              'Fn::Jq':
                - First
                - '. | map(. as $item | [$item])'
                - '{{ describeScalingGroups.scalingGroupInfos }}'
      RateControl: '{{ rateControl }}'
      Outputs:
        thresholdInfos:
          AggregateField: thresholdInfo
          AggregateType: 'Fn::ListJoin'
  - Name: wetherNodifyWebhook
    Action: 'ACS::Choice'
    Description:
      en: アラート通知を送信するかどうかを確認します。
      zh-cn: Checks whether to send an alert notification.
    Properties:
      DefaultTask: alarmNotify
      Choices:
        - When:
            'Fn::Equals':
              - []
              - 'Fn::MergeList':
                  'Fn::MergeList': '{{ instanceThresholdInfo.thresholdInfos }}'
          NextTask: 'ACS::END'
  - Name: alarmNotify
    Action: 'ACS::Notify'
    Description:
      en: インスタンスの割引またはスポット価格がしきい値を超えたことを示すアラート通知を送信します。
      zh-cn: Sends an alert notification that 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
                          - '.[0] | split(", ") | join("") | split("||") | join("|") | split(",") | join("") | split("|###") | join("###")'
                          - 'Fn::Jq':
                              - All
                              - '.[] | map(.[] | tostring)| join(" |")'
                              - 'Fn::Jq':
                                  - All
                                  - 'map(. | .threshold=.threshold+" |\n\n,")'
                                  - 'Fn::Jq':
                                      - All
                                      - '.[] | .scalingGroupId = "### Scaling group ID: "+.scalingGroupId+"\n| Instance type |  Zone|Current price|Discount (%)|\n|:----|----:|:----:|:----|\n,"'
                                      - 'Fn::MergeList':
                                              'Fn::MergeList': '{{ instanceThresholdInfo.thresholdInfos }}'
Outputs:
  allThresholdInfo:
    Type: List
    Value:
      'Fn::Join':
        - ''
        - 'Fn::ListJoin':
            - |
              ### Alarm threshold: {{ threshold }}
            - 'Fn::Jq':
                  - First
                  - '.[0] | split(", ") | join("") | split("||") | join("|") | split(",") | join("") | split("|###") | join("###")'
                  - 'Fn::Jq':
                      - All
                      - '.[] | map(.[] | tostring)| join(" |")'
                      - 'Fn::Jq':
                          - All
                          - 'map(. | .threshold=.threshold+" |\n\n,")'
                          - 'Fn::Jq':
                              - All
                              - '.[] | .scalingGroupId = "### Scaling group ID: "+.scalingGroupId+"\n| Instance type |  Zone|Current price|Discount (%)|\n|:----|----:|:----:|:----|\n,"'
                              - 'Fn::MergeList':
                                      'Fn::MergeList': '{{ instanceThresholdInfo.thresholdInfos }}'
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