ALIYUN::CMS::MetricRuleTemplateDeployment

ALIYUN::CMS::MetricRuleTemplateDeployment类型用于应用报警模板至应用分组。

语法

{
  "Type": "ALIYUN::CMS::MetricRuleTemplateDeployment",
  "Properties": {
    "GroupId": Integer,
    "TemplateIds": List,
    "AppendMode": String,
    "ApplyMode": String,
    "EnableEndTime": Integer,
    "EnableStartTime": Integer,
    "NotifyLevel": Integer,
    "SilenceTime": Integer,
    "Webhook": String
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

GroupId

Integer

应用分组 ID。

关于如何获取应用分组 ID,请参见 DescribeMonitorGroups - 查询应用分组列表

TemplateIds

List

报警模板 ID。

关于如何获取报警模板 ID,请参见 DescribeMetricRuleTemplateList - 查询报警模板列表

AppendMode

String

模板应用策略。

取值:

  • all:删除已选择分组上所有通过报警模板创建的规则,然后按模板创建新的报警规则(默认值)。

  • append:删除已选择分组上通过该报警模板创建的规则,然后按当前模板创建新的报警规则。

ApplyMode

String

模板应用方式。

取值:

  • GROUP_INSTANCE_FIRST:应用分组实例优先。应用报警模板时,以应用分组实例优先,如果应用分组中不存在该实例,则忽略模板中的规则。

  • ALARM_TEMPLATE_FIRST:报警模板实例优先。应用报警模板时,不管应用分组中是否存在该实例,都创建报警规则。

EnableEndTime

Integer

报警生效的结束时间。

取值范围:00~23,表示 00:59 到 23:59。

EnableStartTime

Integer

报警生效的开始时间。

取值范围:00~23,表示 00:00 到 23:00。

NotifyLevel

Integer

报警通知方式。

取值:

  • 2:电话+短信+邮箱+旺旺+钉钉机器人。

  • 3:短信+邮箱+旺旺+钉钉机器人。

  • 4:旺旺+钉钉机器人。

SilenceTime

Integer

通道沉默周期。

单位:秒。默认值:86400。

说明

当监控数据持续超过报警规则阈值时,每个沉默周期内只发送一次报警通知。

Webhook

String

报警发生时会回调指定的 URL 地址并发送 POST 请求。

返回值

Fn::GetAtt

  • RuleIds:报警规则 ID列表。

  • GroupId:应用分组 ID。

示例

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  TemplateIds:
    AssociationPropertyMetadata:
      Parameter:
        Type: String
        Required: false
        MinLength: 1
    AssociationProperty: List[Parameter]
    Type: Json
    Description:
      en: |-
        The ID list of the Alarm Template to be applied.
        For how to get the alarm template ID, see DescribeMetricRuleTemplateList.
    Required: true
    MinLength: 1
  GroupId:
    Type: Number
    Description:
      en: |-
        Apply group ID.
        For how to get the application group ID, see DescribeMonitorGroups.
    Required: true
    MaxValue: 9007199254740991
Resources:
  MetricRuleTemplateDeployment:
    Type: ALIYUN::CMS::MetricRuleTemplateDeployment
    Properties:
      TemplateIds:
        Ref: TemplateIds
      GroupId:
        Ref: GroupId
Outputs:
  RuleIds:
    Description: The IDs of rhe generated rules.
    Value:
      Fn::GetAtt:
        - MetricRuleTemplateDeployment
        - RuleIds
  GroupId:
    Description: The ID of the group that applied the template to.
    Value:
      Fn::GetAtt:
        - MetricRuleTemplateDeployment
        - GroupId
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "TemplateIds": {
      "AssociationPropertyMetadata": {
        "Parameter": {
          "Type": "String",
          "Required": false,
          "MinLength": 1
        }
      },
      "AssociationProperty": "List[Parameter]",
      "Type": "Json",
      "Description": {
        "en": "The ID list of the Alarm Template to be applied.\nFor how to get the alarm template ID, see DescribeMetricRuleTemplateList."
      },
      "Required": true,
      "MinLength": 1
    },
    "GroupId": {
      "Type": "Number",
      "Description": {
        "en": "Apply group ID.\nFor how to get the application group ID, see DescribeMonitorGroups."
      },
      "Required": true,
      "MaxValue": 9007199254740991
    }
  },
  "Resources": {
    "MetricRuleTemplateDeployment": {
      "Type": "ALIYUN::CMS::MetricRuleTemplateDeployment",
      "Properties": {
        "TemplateIds": {
          "Ref": "TemplateIds"
        },
        "GroupId": {
          "Ref": "GroupId"
        }
      }
    }
  },
  "Outputs": {
    "RuleIds": {
      "Description": "The IDs of rhe generated rules.",
      "Value": {
        "Fn::GetAtt": [
          "MetricRuleTemplateDeployment",
          "RuleIds"
        ]
      }
    },
    "GroupId": {
      "Description": "The ID of the group that applied the template to.",
      "Value": {
        "Fn::GetAtt": [
          "MetricRuleTemplateDeployment",
          "GroupId"
        ]
      }
    }
  }
}