ALIYUN::CMS::MetricRuleTemplate类型用于创建报警模板。
语法
{
  "Type": "ALIYUN::CMS::MetricRuleTemplate",
  "Properties": {
    "AlertTemplates": List,
    "Description": String,
    "RestVersion": Integer,
    "TemplateId": Integer,
    "Name": String
  }
}属性
| 属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 | 
| Name | String | 是 | 否 | 报警模板名称。 | 无 | 
| AlertTemplates | List | 否 | 是 | 报警模板。 | 最多添加200个规则。 更多信息,请参见AlertTemplates属性。 | 
| Description | String | 否 | 是 | 报警模板描述信息。 | 无 | 
| RestVersion | Integer | 否 | 否 | 报警模板版本。 | 默认值为0。 | 
| TemplateId | Integer | 否 | 否 | 克隆模板ID。 | 无 | 
AlertTemplates语法
"AlertTemplates": [
  {
    "MetricName": String,
    "Category": String,
    "Escalations": Map,
    "Period": Integer,
    "Webhook": String,
    "Namespace": String,
    "RuleName": String,
    "Selector": String
  }
]AlertTemplates属性
| 属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 | 
| Category | String | 是 | 是 | 产品名称或产品规格缩写。 | 取值: 
 | 
| MetricName | String | 是 | 是 | 监控项名称。 | 无 | 
| Namespace | String | 是 | 是 | 产品的数据命名空间。 | 更多信息,请参见DescribeMetricMetaList或监控指标使用说明。 | 
| RuleName | String | 是 | 是 | 报警规则的名称。 | 无 | 
| Escalations | Map | 否 | 否 | 报警配置。 | 更多信息,请参见Escalations属性。 | 
| Period | Integer | 否 | 是 | 监控数据的聚合周期。 | 默认为监控项对应的最小频率,通常不需要指定。 单位:秒。 | 
| Selector | String | 否 | 是 | 扩展字段选项。 | 无 | 
| Webhook | String | 否 | 否 | 报警发生时的回调URL地址。 | 无 | 
Escalations语法
"Escalations": {
  "Critical": Map,
  "Info": Map,
  "Warn": Map
}Escalations属性
| 属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 | 
| Critical | Map | 是 | 是 | Critical级别报警设置。 | 更多信息,请参见Critical属性。 | 
| Info | Map | 否 | 是 | Info级别报警设置。 | 更多信息,请参见Info属性。 | 
| Warn | Map | 否 | 是 | Warn级别报警设置。 | 更多信息,请参见Warn属性。 | 
Critical语法
"Critical": {
  "ComparisonOperator": String,
  "Times": Integer,
  "Statistics": String,
  "Threshold": String
}Critical属性
| 属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 | 
| ComparisonOperator | String | 是 | 是 | 阈值比较符。 | 取值: 
 | 
| Statistics | String | 是 | 是 | 报警统计方法。 | 无 | 
| Threshold | String | 是 | 是 | 报警阈值。 | 无 | 
| Times | Integer | 是 | 是 | 报警重试次数。 | 无 | 
Info语法
"Info": {
  "ComparisonOperator": String,
  "Times": Integer,
  "Statistics": String,
  "Threshold": String
}Info属性
| 属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 | 
| ComparisonOperator | String | 是 | 是 | 阈值比较符。 | 取值: 
 | 
| Statistics | String | 是 | 是 | 报警统计方法。 | 无 | 
| Threshold | String | 是 | 是 | 报警阈值。 | 无 | 
| Times | Integer | 是 | 是 | 报警重试次数。 | 无 | 
Warn语法
"Warn": {
  "ComparisonOperator": String,
  "Times": Integer,
  "Statistics": String,
  "Threshold": String
}Warn属性
| 属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 | 
| ComparisonOperator | String | 是 | 是 | 阈值比较符。 | 取值: 
 | 
| Statistics | String | 是 | 是 | 报警统计方法。 | 无 | 
| Threshold | String | 是 | 是 | 报警阈值。 | 无 | 
| Times | Integer | 是 | 是 | 报警重试次数。 | 无 | 
返回值
Fn::GetAtt
Id:报警模板ID。
示例
YAML
ROSTemplateFormatVersion: '2015-09-01'
Parameters: {}
Resources:
  MetricRuleTemplate:
    Type: ALIYUN::CMS::MetricRuleTemplate
    Properties:
      AlertTemplates:
        - Category: ecs
          Namespace: acs_ecs_dashboard
          Period: 60
          Webhook: http://ww.aliyun.com
          RuleName: CPU监控
          Selector: ''
          MetricName: cpu_total
          Escalations:
            Critical:
              Statistics: Average
              Threshold: '90'
              ComparisonOperator: GreaterThanOrEqualToThreshold
              Times: 3
            Warn:
              Statistics: Average
              Threshold: '80'
              ComparisonOperator: GreaterThanOrEqualToThreshold
              Times: 3
            Info:
              Statistics: Average
              Threshold: '70'
              ComparisonOperator: GreaterThanOrEqualToThreshold
              Times: 3
        - Category: ecs
          Namespace: acs_ecs_dashboard
          Period: 60
          RuleName: 磁盘监控
          Selector: '{"disk":"/"}'
          MetricName: diskusage_total
          Escalations:
            Critical:
              Statistics: Average
              Threshold: '500'
              ComparisonOperator: GreaterThanOrEqualToThreshold
              Times: 5
      Name: TestMetricRuleTemplate
Outputs:
  Id:
    Description: Alarm template ID.
    Value:
      Fn::GetAtt:
        - MetricRuleTemplate
        - IdJSON
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
  },
  "Resources": {
    "MetricRuleTemplate": {
      "Type": "ALIYUN::CMS::MetricRuleTemplate",
      "Properties": {
        "AlertTemplates": [
          {
            "Category": "ecs",
            "Namespace": "acs_ecs_dashboard",
            "Period": 60,
            "Webhook": "http://ww.aliyun.com",
            "RuleName": "CPU监控",
            "Selector": "",
            "MetricName": "cpu_total",
            "Escalations": {
              "Critical": {
                "Statistics": "Average",
                "Threshold": "90",
                "ComparisonOperator": "GreaterThanOrEqualToThreshold",
                "Times": 3
              },
              "Warn": {
                "Statistics": "Average",
                "Threshold": "80",
                "ComparisonOperator": "GreaterThanOrEqualToThreshold",
                "Times": 3
              },
              "Info": {
                "Statistics": "Average",
                "Threshold": "70",
                "ComparisonOperator": "GreaterThanOrEqualToThreshold",
                "Times": 3
              }
            }
          },
          {
            "Category": "ecs",
            "Namespace": "acs_ecs_dashboard",
            "Period": 60,
            "RuleName": "磁盘监控",
            "Selector": "{\"disk\":\"/\"}",
            "MetricName": "diskusage_total",
            "Escalations": {
              "Critical": {
                "Statistics": "Average",
                "Threshold": "500",
                "ComparisonOperator": "GreaterThanOrEqualToThreshold",
                "Times": 5
              }
            }
          }
        ],
        "Name": "TestMetricRuleTemplate"
      }
    }
  },
  "Outputs": {
    "Id": {
      "Description": "Alarm template ID.",
      "Value": {
        "Fn::GetAtt": [
          "MetricRuleTemplate",
          "Id"
        ]
      }
    }
  }
}