Tous les produits
Search
Centre de documentation

CloudOps Orchestration Service:ACS-ECS-AlarmWhenDiscountAndPriceExceedsThresholdInMultiZoneAndInstanceType

Dernière mise à jour :Aug 11, 2026

Nom du modèle

ACS-ECS-AlarmWhenDiscountAndPriceExceedsThresholdInMultiZoneAndInstanceType : envoie une alerte lorsque la remise ou le prix spot de types d'instance ECS spécifiés dans plusieurs zones dépasse un seuil.

Exécuter maintenant

Description du modèle

Envoie une alerte lorsque la remise ou le prix spot de types d'instance ECS spécifiés dans plusieurs zones dépasse un seuil.

Type de modèle

Automation

Propriétaire

Alibaba Cloud

Paramètres d'entrée

|
**Nom du paramètre**
|
**Description**
|
**Type**
|
**Obligatoire**
|
**Valeur par défaut**
|
**Contraintes**
| | --- | --- | --- | --- | --- | --- | |
zoneId
|
ID de zone
|
List
|
Oui
| | | |
instanceType
|
Type d'instance
|
List
|
Oui
| | | |
threshold
|
Seuil de prix ou de remise.
|
Number
|
Oui
| | | |
webhook
|
URL du webhook DingTalk pour la réception des notifications.
|
String
|
Oui
| | | |
region
|
ID de région.
|
String
|
Non
|
{{ ACS::RegionId }}
| | |
taskType
|
Type de tâche de surveillance.
|
String
|
Non
|
Discount
| | |
rateControl
|
Taux de concurrence pour l'exécution des tâches.
|
Json
|
Non
|
{‘Mode’: ‘Concurrency’, ‘MaxErrors’: 100, ‘Concurrency’: 10}
| | |
OOSAssumeRole
|
Rôle RAM assumé par OOS.
|
String
|
Non
|
OOSServiceRole
| |

Paramètres de sortie

|
**Nom du paramètre**
|
**Description**
|
**Type**
| | --- | --- | --- | |
allThresholdInfo
| |
Json
|

Politique d'accès requise pour l'exécution

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

Détails

ACS-ECS-AlarmWhenDiscountAndPriceExceedsThresholdInMultiZoneAndInstanceType

Contenu du modèle

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