Todos os produtos
Search
Central de documentação

CloudOps Orchestration Service:ACS-ECS-AlarmWhenDiscountAndPriceExceedsThresholdInMultiZoneAndInstanceType

Última atualização: Jun 28, 2026

Nome do modelo

ACS-ECS-AlarmWhenDiscountAndPriceExceedsThresholdInMultiZoneAndInstanceType: Envia um alerta quando o desconto ou o preço spot de tipos de instância ECS especificados em várias zonas ultrapassa um limiar.

Executar agora

Descrição do modelo

Envia um alerta quando o desconto ou o preço spot de tipos de instância ECS especificados em várias zonas ultrapassa um limiar.

Tipo de modelo

Automation

Proprietário

Alibaba Cloud

Parâmetros de entrada

Nome do parâmetro

Descrição

Tipo

Obrigatório

Valor padrão

Restrições

zoneId

ID da zona

List

Sim

instanceType

Tipo de instância

List

Sim

threshold

Limiar de preço ou desconto.

Number

Sim

webhook

URL do webhook do DingTalk para receber notificações.

String

Sim

region

ID da região.

String

Não

{{ ACS::RegionId }}

taskType

Tipo de tarefa de monitoramento.

String

Não

Discount

rateControl

Taxa de concorrência para execução da tarefa.

Json

Não

{‘Mode’: ‘Concurrency’, ‘MaxErrors’: 100, ‘Concurrency’: 10}

OOSAssumeRole

Função RAM assumida pelo OOS.

String

Não

OOSServiceRole

Parâmetros de saída

Nome do parâmetro

Descrição

Tipo

allThresholdInfo

Json

Política de acesso necessária para execução

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

Detalhes

ACS-ECS-AlarmWhenDiscountAndPriceExceedsThresholdInMultiZoneAndInstanceType

Conteúdo do modelo

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