ALIYUN::CMS::ResourceMetricRule类型用于为指定资源的指定监控项设置一条阈值报警规则。
语法
{
  "Type": "ALIYUN::CMS::ResourceMetricRule",
  "Properties": {
    "NoEffectiveInterval": String,
    "ContactGroups": List,
    "SilenceTime": Integer,
    "RuleId": String,
    "Period": Integer,
    "Prometheus": Map,
    "Labels": List,
    "EffectiveInterval": String,
    "NoDataPolicy": String,
    "Namespace": String,
    "MetricName": String,
    "DeletionForce": Boolean,
    "Escalations": Map,
    "EmailSubject": String,
    "CompositeExpression": Map,
    "Webhook": String,
    "Resources": List,
    "RuleName": String,
    "Interval": Integer
  }
}属性
| 属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 | 
| ContactGroups | List | 是 | 是 | 报警联系组。 | 报警通知会发送给该报警联系组中的报警联系人。 说明  报警联系组包含报警联系人,可以包含一个或多个报警联系人。关于如何创建报警联系人和报警联系组,请参见PutContact和PutContactGroup。 | 
| Escalations | Map | 是 | 是 | 报警详情。 | 更多信息,请参见Escalations属性。 | 
| MetricName | String | 是 | 是 | 监控项名称。 | 关于如何查询监控项名称,请参见云产品监控项。 说明  当您为企业云监控创建Prometheus报警规则时,该参数为指标仓库名称。关于如何获取指标仓库名称,请参见DescribeHybridMonitorNamespaceList。 | 
| Namespace | String | 是 | 是 | 云产品的数据命名空间。 | 关于如何查询云产品的数据命名空间,请参见云产品监控项。 说明  当您为企业云监控创建Prometheus报警规则时,该参数必须为acs_prometheus。 | 
| Resources | List | 是 | 是 | 资源信息。 | 例如: | 
| CompositeExpression | Map | 否 | 是 | 多指标的报警条件。 | 更多信息,请CompositeExpression属性。 说明  单指标和多指标互斥,不能同时设置。 | 
| DeletionForce | Boolean | 否 | 是 | 是否强制删除。 | 取值: 
 | 
| EffectiveInterval | String | 否 | 是 | 报警规则的生效时间范围。 | 时间范围:00:00-23:59。 | 
| EmailSubject | String | 否 | 是 | 报警邮件主题。 | 无 | 
| Interval | Integer | 否 | 是 | 报警规则的触发周期。 | 单位:秒。 说明  关于如何查询监控项的统计周期,请参见云产品监控项。 | 
| Labels | List | 否 | 是 | 标签信息。 | 更多信息,请参见Labels属性。 | 
| NoDataPolicy | String | 否 | 是 | 无监控数据时报警的处理方式。 | 取值: 
 | 
| NoEffectiveInterval | String | 否 | 是 | 报警规则的失效时间范围。 | 时间范围:00:00-23:59。 | 
| Period | Integer | 否 | 是 | 监控项的统计周期。 | 单位:秒。默认值:监控项的原始上报周期。 说明  关于如何查询监控项的统计周期,请参见附录1 云产品监控指标。 | 
| Prometheus | Map | 否 | 是 | Prometheus报警。 | 更多信息,请参见Prometheus属性。 说明  当您为企业云监控创建Prometheus报警规则时,该参数必须设置。 | 
| RuleId | String | 否 | 否 | 报警规则ID。 | 您可以输入新的报警规则ID或输入已存在的报警规则ID。关于如何查询报警规则ID,请参见DescribeMetricRuleList。 说明  输入新的报警规则ID,表示创建一条新的阈值报警规则。 | 
| RuleName | String | 否 | 是 | 报警规则名称。 | 您可以输入新的报警规则名称或输入云监控已存在的报警规则名称。关于如何查询报警规则名称,请参见DescribeMetricRuleList。 说明  输入新的报警规则名称,表示创建一条新的阈值报警规则。 | 
| SilenceTime | Integer | 否 | 是 | 通道沉默周期。 | 单位:秒。默认值:86400。 说明  通道沉默周期是指报警发生后未恢复正常,间隔多久重新发送一次报警通知。 | 
| Webhook | String | 否 | 是 | 报警发生回调时指定的URL地址,向URL发送POST请求。 | 无 | 
Prometheus语法
"Prometheus": {
  "Annotations": List,
  "PromQL": String,
  "Times": Integer,
  "Level": String
}Prometheus属性
| 属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 | 
| Level | String | 是 | 是 | 报警级别。 | 取值: 
 | 
| PromQL | String | 是 | 是 | PromQL查询语句。 | 无 | 
| Times | Integer | 是 | 是 | 发出报警通知需要达到报警条件的次数。 | 无 | 
| Annotations | List | 否 | 是 | Prometheus报警时,将注释的键和值进行渲染。多指标报警条件之间的关系。 | 更多信息,请参见Annotations属性。 说明  该参数的效果与Prometheus参数取值为Annotation的效果相同。 | 
Annotations语法
"Annotations": [
  {
    "Value": String,
    "Key": String
  }
]Annotations属性
| 属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 | 
| Key | String | 否 | 是 | 注释的键。 | 无 | 
| Value | String | 否 | 是 | 注释的值。 | 无 | 
Labels语法
"Labels": [
  {
    "Value": String,
    "Key": String
  }
]Labels属性
| 属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 | 
| Key | String | 是 | 是 | 标签键。 | 无 | 
| Value | String | 否 | 是 | 标签值。 | 无 | 
Escalations语法
"Escalations": {
  "Critical": Map,
  "Info": Map,
  "Warn": Map
}Escalations属性
| 属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 | 
| Critical | Map | 否 | 是 | 严重级别报警详情。 | 更多信息,请参见Critical属性。 | 
| Info | Map | 否 | 是 | 信息级别报警详情。 | 更多信息,请参见Info属性。 | 
| Warn | Map | 否 | 是 | 警告级别报警详情。 | 更多信息,请参见Warn属性。 | 
Critical语法
"Critical": {
  "ComparisonOperator": String,
  "Times": Integer,
  "Statistics": String,
  "Threshold": String
}Critical属性
| 属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 | 
| ComparisonOperator | String | 是 | 是 | 严重级别阈值比较符。 | 取值: 
 说明  您需要设置报警级别Critical(严重)、Warn(警告)或Info(信息)至少一个,且该报警级别中的参数Statistics、ComparisonOperator、Threshold和Times必须同时设置。 | 
| Statistics | String | 是 | 是 | 严重级别报警统计方法。 | 取值: 
 说明  您需要设置报警级别Critical(严重)、Warn(警告)或Info(信息)至少一个,且该报警级别中的参数Statistics、ComparisonOperator、Threshold和Times必须同时设置。 | 
| Threshold | String | 是 | 是 | 严重级别报警阈值。 | 说明  您需要设置报警级别Critical(严重)、Warn(警告)或Info(信息)至少一个,且该报警级别中的参数Statistics、ComparisonOperator、Threshold和Times必须同时设置。 | 
| Times | Integer | 是 | 是 | 严重级别报警重试次数。 | 说明  您需要设置报警级别Critical(严重)、Warn(警告)或Info(信息)至少一个,且该报警级别中的参数Statistics、ComparisonOperator、Threshold和Times必须同时设置。 | 
Info语法
"Info": {
  "ComparisonOperator": String,
  "Times": Integer,
  "Statistics": String,
  "Threshold": String
}Info属性
| 属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 | 
| ComparisonOperator | String | 是 | 是 | 信息级别阈值比较符。 | 取值: 
 说明  您需要设置报警级别Critical(严重)、Warn(警告)或Info(信息)至少一个,且该报警级别中的参数Statistics、ComparisonOperator、Threshold和Times必须同时设置。 | 
| Statistics | String | 是 | 是 | 信息级别报警统计方法。 | 取值: 
 说明  您需要设置报警级别Critical(严重)、Warn(警告)或Info(信息)至少一个,且该报警级别中的参数Statistics、ComparisonOperator、Threshold和Times必须同时设置。 | 
| Threshold | String | 是 | 是 | 信息级别报警阈值。 | 说明  您需要设置报警级别Critical(严重)、Warn(警告)或Info(信息)至少一个,且该报警级别中的参数Statistics、ComparisonOperator、Threshold和Times必须同时设置。 | 
| Times | Integer | 是 | 是 | 信息级别报警重试次数。 | 说明  您需要设置报警级别Critical(严重)、Warn(警告)或Info(信息)至少一个,且该报警级别中的参数Statistics、ComparisonOperator、Threshold和Times必须同时设置。 | 
Warn语法
"Warn": {
  "ComparisonOperator": String,
  "Times": Integer,
  "Statistics": String,
  "Threshold": String
}Warn属性
| 属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 | 
| ComparisonOperator | String | 是 | 是 | 警告级别阈值比较符。 | 取值: 
 说明  你需要设置报警级别Critical(严重)、Warn(警告)或Info(信息)至少一个,且该报警级别中的参数Statistics、ComparisonOperator、Threshold和Times必须同时设置。 | 
| Statistics | String | 是 | 是 | 警告级别报警统计方法。 | 取值: 
 说明  您需要设置报警级别Critical(严重)、Warn(警告)或Info(信息)至少一个,且该报警级别中的参数Statistics、ComparisonOperator、Threshold和Times必须同时设置。 | 
| Threshold | String | 是 | 是 | 警告级别报警阈值。 | 说明  您需要设置报警级别Critical(严重)、Warn(警告)或Info(信息)至少一个,且该报警级别中的参数Statistics、ComparisonOperator、Threshold和Times必须同时设置。 | 
| Times | Integer | 是 | 是 | 警告级别报警重试次数。 | 说明  您需要设置报警级别Critical(严重)、Warn(警告)或Info(信息)至少一个,且该报警级别中的参数Statistics、ComparisonOperator、Threshold和Times必须同时设置。 | 
CompositeExpression语法
"CompositeExpression": {
  "Times": Integer,
  "ExpressionRaw": String,
  "ExpressionListJoin": String,
  "Level": String,
  "ExpressionList": List
}CompositeExpression属性
| 属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 | 
| Level | String | 是 | 是 | 报警级别。 | 取值: 
 | 
| Times | Integer | 是 | 是 | 发出报警通知需要达到报警条件的次数。 | 无 | 
| ExpressionList | List | 否 | 是 | 标准创建的报警条件列表。 | 更多信息,请参见ExpressionList属性。 | 
| ExpressionListJoin | String | 否 | 是 | 多指标报警条件之间的关系。 | 取值: 
 | 
| ExpressionRaw | String | 否 | 是 | 表达式创建的报警条件。 | 包括但不限于以下情况: 
 | 
ExpressionList语法
"ExpressionList": [
  {
    "MetricName": String,
    "ComparisonOperator": String,
    "Period": Integer,
    "Statistics": String,
    "Threshold": String
  }
]ExpressionList属性
| 属性名称 | 类型 | 必须 | 允许更新 | 描述 | 约束 | 
| ComparisonOperator | String | 是 | 是 | 阈值比较符。 | 取值: 
 | 
| MetricName | String | 是 | 是 | 云产品的监控项名称。 | 无 | 
| Period | Integer | 是 | 是 | 监控项的聚合周期。 | 单位:秒。 | 
| Statistics | String | 是 | 是 | 监控项的统计方法。 | 取值: 
 说明  $为监控项的统一前缀符号。关于云监控支持的云产品,请参见云产品监控项。 | 
| Threshold | String | 是 | 是 | 报警阈值。 | 无 | 
返回值
Fn::GetAtt
- RuleId:报警规则ID。 
- RuleName:报警规则名称。 
示例
JSON格式
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "ContactGroups": {
      "Type": "Json",
      "Description": "The alert contact group.\nThe alert notifications are sent to the contacts that belong to the alert contact group.\nNote: An alert contact group can contain one or more alert contacts. For information about how to create alert contacts and alert contact groups, see PutContact and PutContactGroup.",
      "MinLength": 1
    },
    "Namespace": {
      "Type": "String",
      "Description": "The namespace of the cloud service.\nFor information about how to query the namespace of a cloud service, Appendix 1: Metrics.\nNote: If you create a Prometheus alert rule for Hybrid Cloud Monitoring, you must set this parameter to acs_prometheus."
    },
    "MetricName": {
      "Type": "String",
      "Description": "The name of the metric.\nFor information about how to query the name of a metric, see Appendix 1: Metrics.\nNote: If you create a Prometheus alert rule for Hybrid Cloud Monitoring, you must set this parameter to the name of the namespace. For information about how to obtain the name of a namespace, see DescribeHybridMonitorNamespaceList."
    },
    "Escalations": {
      "Type": "Json",
      "Description": "You must select at least one of the Critical, Warn, and Info alert levels.",
      "MinLength": 1
    },
    "Resources": {
      "Type": "Json",
      "Description": "The information about the resource.\nExamples: [{\"instanceId\":\"i-uf6j91r34rnwawoo****\"}] and [{\"userId\":\"100931896542****\"}].\nFor information about the supported dimensions that are used to query resources, see Appendix 1: Metrics.",
      "MinLength": 1
    }
  },
  "Resources": {
    "ResourceMetricRule": {
      "Type": "ALIYUN::CMS::ResourceMetricRule",
      "Properties": {
        "ContactGroups": {
          "Ref": "ContactGroups"
        },
        "Namespace": {
          "Ref": "Namespace"
        },
        "MetricName": {
          "Ref": "MetricName"
        },
        "Resources": {
          "Ref": "Resources"
        },
        "Escalations": {
          "Ref": "Escalations"
        }
      }
    }
  },
  "Outputs": {
    "RuleId": {
      "Description": "The ID of the alert rule.",
      "Value": {
        "Fn::GetAtt": [
          "ResourceMetricRule",
          "RuleId"
        ]
      }
    },
    "RuleName": {
      "Description": "The name of the alert rule.",
      "Value": {
        "Fn::GetAtt": [
          "ResourceMetricRule",
          "RuleName"
        ]
      }
    }
  }
}