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
  }
}

属性

属性名称 类型 必须 允许更新 描述 约束
NoEffectiveInterval String 报警规则的失效时间范围。 时间范围:00:00-23:59。
ContactGroups List 报警联系组。 报警通知会发送给该报警联系组中的报警联系人。
说明 报警联系组包含报警联系人,可以包含一个或多个报警联系人。关于如何创建报警联系人和报警联系组,请参见PutContactPutContactGroup
SilenceTime Integer 通道沉默周期。 单位:秒。默认值:86400。
说明 通道沉默周期是指报警发生后未恢复正常,间隔多久重新发送一次报警通知。
RuleId String 报警规则ID。 您可以输入新的报警规则ID或输入已存在的报警规则ID。关于如何查询报警规则ID,请参见DescribeMetricRuleList
说明 输入新的报警规则ID,表示创建一条新的阈值报警规则。
Period Integer 监控项的统计周期。 单位:秒。默认值:监控项的原始上报周期。
说明 关于如何查询监控项的统计周期,请参见概览
Prometheus Map Prometheus报警。 更多信息,请参见Prometheus属性
说明 当您为企业云监控创建Prometheus报警规则时,该参数必须设置。
Labels List 标签信息。 更多信息,请参见Labels属性
EffectiveInterval String 报警规则的生效时间范围。 时间范围:00:00-23:59。
NoDataPolicy String 无监控数据时报警的处理方式。 取值:
  • KEEP_LAST_STATE(默认值):不做任何处理。
  • INSUFFICIENT_DATA:报警内容为无数据。
  • OK:正常。
Namespace String 云产品的数据命名空间。 关于如何查询云产品的数据命名空间,请参见云产品监控项
说明 当您为企业云监控创建Prometheus报警规则时,该参数必须为acs_prometheus。
MetricName String 监控项名称。 关于如何查询监控项名称,请参见云产品监控项
说明 当您为企业云监控创建Prometheus报警规则时,该参数为指标仓库名称。关于如何获取指标仓库名称,请参见DescribeHybridMonitorNamespaceList
DeletionForce Boolean 是否强制删除。 取值:
  • true:强制删除。
  • false:非强制删除。
Escalations Map 报警详情。 更多信息,请参见Escalations属性
EmailSubject String 报警邮件主题。
CompositeExpression Map 多指标的报警条件。 更多信息,请参见CompositeExpression属性
说明 单指标和多指标互斥,不能同时设置。
Webhook String 报警发生回调时指定的URL地址,向URL发送POST请求。
Resources List 资源信息。 例如:[{"instanceId":"i-uf6j91r34rnwawoo****"}][{"userId":"100931896542****"}]。关于资源信息支持的维度Dimensions,请参见云产品监控项
RuleName String 报警规则名称。 您可以输入新的报警规则名称或输入云监控已存在的报警规则名称。关于如何查询报警规则名称,请参见DescribeMetricRuleList
说明 输入新的报警规则名称,表示创建一条新的阈值报警规则。
Interval Integer 报警规则的触发周期。 单位:秒。
说明 关于如何查询监控项的统计周期,请参见云产品监控项

Prometheus语法

"Prometheus": {
  "Annotations": List,
  "PromQL": String,
  "Times": Integer,
  "Level": String
}

Prometheus属性

属性名称 类型 必须 允许更新 描述 约束
Annotations List Prometheus报警时,将注释的键和值进行渲染。多指标报警条件之间的关系。 更多信息,请参见Annotations属性
说明 该参数的效果与Prometheus参数取值为Annotation的效果相同。
PromQL String PromQL查询语句。
Times Integer 发出报警通知需要达到报警条件的次数。
Level String 报警级别。 取值:
  • Critical:严重。
  • Warn:警告。
  • Info:信息。

Annotations语法

"Annotations": [
  {
    "Value": String,
    "Key": String
  }
]

Annotations属性

属性名称 类型 必须 允许更新 描述 约束
Value String 注释的值。
Key String 注释的键。

Labels语法

"Labels": [
  {
    "Value": String,
    "Key": String
  }
]

Labels属性

属性名称 类型 必须 允许更新 描述 约束
Value String 标签值。
Key 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 严重级别阈值比较符。 取值:
  • GreaterThanOrEqualToThreshold:大于等于。
  • GreaterThanThreshold:大于。
  • LessThanOrEqualToThreshold:小于等于。
  • LessThanThreshold:小于。
  • NotEqualToThreshold:不等于。
  • GreaterThanYesterday:同比昨天时间上涨。
  • LessThanYesterday:同比昨天时间下降。
  • GreaterThanLastWeek:同比上周同一时间上涨。
  • LessThanLastWeek:同比上周同一时间下降。
  • GreaterThanLastPeriod:环比上周期上涨。
  • LessThanLastPeriod:环比上周期下降。
说明 您需要设置报警级别Critical(严重)、Warn(警告)或Info(信息)至少一个,且该报警级别中的参数Statistics、ComparisonOperator、Threshold和Times必须同时设置。
Times Integer 严重级别报警重试次数。
说明 您需要设置报警级别Critical(严重)、Warn(警告)或Info(信息)至少一个,且该报警级别中的参数Statistics、ComparisonOperator、Threshold和Times必须同时设置。
Statistics String 严重级别报警统计方法。 取值:
  • Maximum:最大值。
  • Minimum:最小值。
  • Average:平均值。
  • Availability:可用率。
说明 您需要设置报警级别Critical(严重)、Warn(警告)或Info(信息)至少一个,且该报警级别中的参数Statistics、ComparisonOperator、Threshold和Times必须同时设置。
Threshold String 严重级别报警阈值。
说明 您需要设置报警级别Critical(严重)、Warn(警告)或Info(信息)至少一个,且该报警级别中的参数Statistics、ComparisonOperator、Threshold和Times必须同时设置。

Info语法

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

Info属性

属性名称 类型 必须 允许更新 描述 约束
ComparisonOperator String 信息级别阈值比较符。 取值:
  • GreaterThanOrEqualToThreshold:大于等于。
  • GreaterThanThreshold:大于。
  • LessThanOrEqualToThreshold:小于等于。
  • LessThanThreshold:小于。
  • NotEqualToThreshold:不等于。
  • GreaterThanYesterday:同比昨天时间上涨。
  • LessThanYesterday:同比昨天时间下降。
  • GreaterThanLastWeek:同比上周同一时间上涨。
  • LessThanLastWeek:同比上周同一时间下降。
  • GreaterThanLastPeriod:环比上周期上涨。
  • LessThanLastPeriod:环比上周期下降。
说明 您需要设置报警级别Critical(严重)、Warn(警告)或Info(信息)至少一个,且该报警级别中的参数Statistics、ComparisonOperator、Threshold和Times必须同时设置。
Times Integer 信息级别报警重试次数。
说明 您需要设置报警级别Critical(严重)、Warn(警告)或Info(信息)至少一个,且该报警级别中的参数Statistics、ComparisonOperator、Threshold和Times必须同时设置。
Statistics String 信息级别报警统计方法。 取值:
  • Maximum:最大值。
  • Minimum:最小值。
  • Average:平均值。
  • Availability:可用率。
说明 您需要设置报警级别Critical(严重)、Warn(警告)或Info(信息)至少一个,且该报警级别中的参数Statistics、ComparisonOperator、Threshold和Times必须同时设置。
Threshold String 信息级别报警阈值。
说明 您需要设置报警级别Critical(严重)、Warn(警告)或Info(信息)至少一个,且该报警级别中的参数Statistics、ComparisonOperator、Threshold和Times必须同时设置。

Warn语法

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

Warn属性

属性名称 类型 必须 允许更新 描述 约束
ComparisonOperator String 警告级别阈值比较符。 取值:
  • GreaterThanOrEqualToThreshold:大于等于。
  • GreaterThanThreshold:大于。
  • LessThanOrEqualToThreshold:小于等于。
  • LessThanThreshold:小于。
  • NotEqualToThreshold:不等于。
  • GreaterThanYesterday:同比昨天时间上涨。
  • LessThanYesterday:同比昨天时间下降。
  • GreaterThanLastWeek:同比上周同一时间上涨。
  • LessThanLastWeek:同比上周同一时间下降。
  • GreaterThanLastPeriod:环比上周期上涨。
  • LessThanLastPeriod:环比上周期下降。
说明 你需要设置报警级别Critical(严重)、Warn(警告)或Info(信息)至少一个,且该报警级别中的参数Statistics、ComparisonOperator、Threshold和Times必须同时设置。
Times Integer 警告级别报警重试次数。
说明 您需要设置报警级别Critical(严重)、Warn(警告)或Info(信息)至少一个,且该报警级别中的参数Statistics、ComparisonOperator、Threshold和Times必须同时设置。
Statistics String 警告级别报警统计方法。 取值:
  • Maximum:最大值。
  • Minimum:最小值。
  • Average:平均值。
  • Availability:可用率。
说明 您需要设置报警级别Critical(严重)、Warn(警告)或Info(信息)至少一个,且该报警级别中的参数Statistics、ComparisonOperator、Threshold和Times必须同时设置。
Threshold String 警告级别报警阈值。
说明 您需要设置报警级别Critical(严重)、Warn(警告)或Info(信息)至少一个,且该报警级别中的参数Statistics、ComparisonOperator、Threshold和Times必须同时设置。

CompositeExpression语法

"CompositeExpression": {
  "Times": Integer,
  "ExpressionRaw": String,
  "ExpressionListJoin": String,
  "Level": String,
  "ExpressionList": List
}

CompositeExpression属性

属性名称 类型 必须 允许更新 描述 约束
Times Integer 发出报警通知需要达到报警条件的次数。
ExpressionRaw String 表达式创建的报警条件。 包括但不限于以下情况:
  • 为部分资源设置报警黑名单,例如:$instanceId != 'i-io8kfvcpp7x5****' && $Average > 50,表示当报警规则中的实例i-io8kfvcpp7x5****的Average大于50时,也不会产生报警。
  • 对规则中的指定实例设置特殊报警阈值,例如:$Average > ($instanceId == 'i-io8kfvcpp7x5****'? 80: 50),表示当报警规则中的实例i-io8kfvcpp7x5****的Average大于80时,才报警,其他实例的Average大于50,即可报警。
  • 对规则中超过阈值的实例数量进行限制,例如:count($Average > 20) > 3,表示当报警规则中的Average大于20的实例数大于3个时,才进行报警。
ExpressionListJoin String 多指标报警条件之间的关系。 取值:
  • &&:当所有指标都符合报警条件时,才触发报警。
  • ||:其中一个指标符合报警条件,即触发报警。
Level String 报警级别。 取值:
  • Critical:严重。
  • Warn:警告。
  • Info:信息。
ExpressionList List 标准创建的报警条件列表。 更多信息,请参见ExpressionList属性

ExpressionList语法

"ExpressionList": [
  {
    "MetricName": String,
    "ComparisonOperator": String,
    "Period": Integer,
    "Statistics": String,
    "Threshold": String
  }
]

ExpressionList属性

属性名称 类型 必须 允许更新 描述 约束
MetricName String 云产品的监控项名称。
ComparisonOperator String 阈值比较符。 取值:
  • GreaterThanOrEqualToThreshold:大于等于。
  • GreaterThanThreshold:大于。
  • LessThanOrEqualToThreshold:小于等于。
  • LessThanThreshold:小于。
  • NotEqualToThreshold:不等于。
  • GreaterThanYesterday:同比昨天时间上涨。
  • LessThanYesterday:同比昨天时间下降。
  • GreaterThanLastWeek:同比上周同一时间上涨。
  • LessThanLastWeek:同比上周同一时间下降。
  • GreaterThanLastPeriod:环比上周期上涨。
  • LessThanLastPeriod:环比上周期下降。
Period Integer 监控项的聚合周期。 单位:秒。
Statistics String 监控项的统计方法。 取值:
  • $Maximum:最大值。
  • $Minimum:最小值。
  • $Average:平均值。
  • $Availability:可用率(通常用于站点监控)。
说明 $为监控项的统一前缀符号。关于云监控支持的云产品,请参见云产品监控项
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"
        ]
      }
    }
  }
}