ALIYUN::CMS::MetricRuleTemplate类型用于创建报警模板。

语法

{
  "Type": "ALIYUN::CMS::MetricRuleTemplate",
  "Properties": {
    "AlertTemplates": List,
    "Description": String,
    "RestVersion": Integer,
    "TemplateId": Integer,
    "Name": String
  }
}

属性

属性名称类型必须允许更新描述约束
AlertTemplatesList报警模板。最多添加200个规则。

更多信息,请参见AlertTemplates属性

DescriptionString报警模板描述信息。
RestVersionInteger报警模板版本。默认值为0。
TemplateIdInteger克隆模板ID。
NameString报警模板名称。

AlertTemplates语法

"AlertTemplates": [
  {
    "MetricName": String,
    "Category": String,
    "Escalations": Map,
    "Period": Integer,
    "Webhook": String,
    "Namespace": String,
    "RuleName": String,
    "Selector": String
  }
]

AlertTemplates属性

属性名称类型必须允许更新描述约束
MetricNameString监控项名称。
CategoryString产品名称或产品规格缩写。取值:
  • ecs:云服务器。
  • rds:阿里云关系型数据库。
  • ads:云原生数据仓库AnalyticDB MySQL版。
  • slb:负载均衡。
  • vpc:专有网络。
  • apigateway:API网关。
  • cdn:内容分发网络。
  • cs:容器服务Kubernetes版。
  • dcdn:全站加速。
  • ddos:DDoS高防。
  • eip:弹性公网IP。
  • elasticsearch:阿里云Elasticsearch。
  • emr:阿里云E-MapReduce。
  • ess:弹性伸缩。
  • hbase:云数据库HBase版。
  • iot_edge:物联网边缘计算。
  • k8s_pod:k8s pod。
  • kvstore_sharding:Redis集群版。
  • kvstore_splitrw:Redis读写分离版。
  • kvstore_standard:Redis标准版。
  • memcache:云数据库Memcache版。
  • mns:消息服务。
  • mongodb:云数据库MongoDB版副本集实例。
  • mongodb_cluster:云数据库MongoDB版单节点实例。
  • mongodb_sharding:云数据库MongoDB版分片集群实例。
  • mq_topic:消息服务TOPIC。
  • ocs:云数据库Memcache版。
  • opensearch:开放搜索。
  • oss:对象存储服务。
  • polardb:云数据库PolarDB。
  • petadata:HybridDB for MySQL。
  • scdn:安全加速。
  • sharebandwidthpackages:共享带宽包。
  • sls:日志服务。
  • vpn:VPN网关。
EscalationsMap报警配置。更多信息,请参见Escalations属性
PeriodInteger监控数据的聚合周期。默认为监控项对应的最小频率,通常不需要指定。

单位:秒。

WebhookString报警发生时的回调URL地址。
NamespaceString产品的数据命名空间。更多信息,请参见DescribeMetricMetaList监控项使用说明
RuleNameString报警规则的名称。
SelectorString扩展字段选项。

Escalations语法

"Escalations": {
  "Critical": Map,
  "Info": Map,
  "Warn": Map
}

Escalations属性

属性名称类型必须允许更新描述约束
CriticalMapCritical级别报警设置。更多信息,请参见Critical属性
InfoMapInfo级别报警设置。更多信息,请参见Info属性
WarnMapWarn级别报警设置。更多信息,请参见Warn属性

Critical语法

"Critical": {
  "ComparisonOperator": String,
  "Times": Integer,
  "Statistics": String,
  "Threshold": String
}

Critical属性

属性名称类型必须允许更新描述约束
ComparisonOperatorString阈值比较符。取值:
  • GreaterThanOrEqualToThreshold:大于等于。
  • GreaterThanThreshold:大于。
  • LessThanOrEqualToThreshold:小于等于。
  • LessThanThreshold:小于。
  • NotEqualToThreshold:不等。
  • GreaterThanYesterday:同比昨天时间上涨。
  • LessThanYesterday:同比昨天时间下降。
  • GreaterThanLastWeek:同比上周同一时间上涨。
  • LessThanLastWeek:同比上周同一时间下降。
  • GreaterThanLastPeriod:环比上周期上涨。
  • LessThanLastPeriod:环比上周期下降。
TimesInteger报警重试次数。
StatisticsString报警统计方法。
ThresholdString报警阈值。

Info语法

"Info": {
  "ComparisonOperator": String,
  "Times": Integer,
  "Statistics": String,
  "Threshold": String
}

Info属性

属性名称类型必须允许更新描述约束
ComparisonOperatorString阈值比较符。取值:
  • GreaterThanOrEqualToThreshold:大于等于。
  • GreaterThanThreshold:大于。
  • LessThanOrEqualToThreshold:小于等于
  • LessThanThreshold:小于。
  • NotEqualToThreshold:不等。
  • GreaterThanYesterday:同比昨天时间上涨。
  • LessThanYesterday:同比昨天时间下降。
  • GreaterThanLastWeek:同比上周同一时间上涨。
  • LessThanLastWeek:同比上周同一时间下降。
  • GreaterThanLastPeriod:环比上周期上涨。
  • LessThanLastPeriod:环比上周期下降。
TimesInteger报警重试次数。
StatisticsString报警统计方法。
ThresholdString报警阈值。

Warn语法

"Warn": {
  "ComparisonOperator": String,
  "Times": Integer,
  "Statistics": String,
  "Threshold": String
}

Warn属性

属性名称类型必须允许更新描述约束
ComparisonOperatorString阈值比较符。取值:
  • GreaterThanOrEqualToThreshold:大于等于。
  • GreaterThanThreshold:大于。
  • LessThanOrEqualToThreshold:小于等于。
  • LessThanThreshold:小于。
  • NotEqualToThreshold:不等。
  • GreaterThanYesterday:同比昨天时间上涨。
  • LessThanYesterday:同比昨天时间下降。
  • GreaterThanLastWeek:同比上周同一时间上涨。
  • LessThanLastWeek:同比上周同一时间下降。
  • GreaterThanLastPeriod:环比上周期上涨。
  • LessThanLastPeriod:环比上周期下降。
TimesInteger报警重试次数。
StatisticsString报警统计方法。
ThresholdString报警阈值。

返回值

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
            - Id
  • JSON格式

    {
      "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"
            ]
          }
        }
      }
    }