All Products
Search
Document Center

Resource Orchestration Service:ALIYUN::CMS::MetricRuleTemplate

Last Updated:Aug 22, 2023

ALIYUN::CMS::MetricRuleTemplate is used to create an alert template.

Syntax

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

Properties

Property

Type

Required

Editable

Description

Constraint

AlertTemplates

List

No

Yes

The details of alert rules that are generated based on the alert template.

You can specify up to 200 alert rules.

For more information, see AlertTemplates properties.

Description

String

No

Yes

The description of the alert template.

None.

RestVersion

Integer

No

No

The version of the alert template.

Default value: 0.

TemplateId

Integer

No

No

The ID of the template to be cloned.

None.

Name

String

Yes

No

The name of the alert template.

None.

AlertTemplates syntax

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

AlertTemplates properties

Property

Type

Required

Editable

Description

Constraint

MetricName

String

Yes

Yes

The name of the metric.

None.

Category

String

Yes

Yes

The abbreviation of the service name.

Valid values:

  • ecs: Elastic Compute Service (ECS)

  • rds: ApsaraDB RDS

  • ads: AnalyticDB for MySQL

  • slb: Server Load Balancer (SLB)

  • vpc: Virtual Private Cloud (VPC)

  • apigateway: API Gateway

  • cdn: Alibaba Cloud CDN (CDN)

  • cs: Container Service for Kubernetes (ACK)

  • dcdn: Dynamic Route for CDN (DCDN)

  • ddos: Anti-DDoS Pro and Anti-DDoS Premium

  • eip: Elastic IP Address (EIP)

  • elasticsearch: Elasticsearch

  • emr: E-MapReduce (EMR)

  • ess: Auto Scaling (ESS)

  • hbase: ApsaraDB for HBase

  • iot_edge: IoT Edge

  • k8s_pod: pods in ACK

  • kvstore_sharding: ApsaraDB for Redis that uses the cluster master-replica architecture

  • kvstore_splitrw: ApsaraDB for Redis that uses the read/write splitting architecture

  • kvstore_standard: ApsaraDB for Redis that uses the standard master-replica architecture

  • memcache: ApsaraDB for Memcache

  • mns: Message Service (MNS)

  • mongodb: ApsaraDB for MongoDB that uses the replica set architecture

  • ApsaraDB for MongoDB that uses the standalone architecture

  • mongodb_sharding: ApsaraDB for MongoDB that uses the sharded cluster architecture

  • mq_topic: MNS topics

  • ocs: ApsaraDB for Memcache (OCS)

  • opensearch: Open Search

  • oss: Object Storage Service (OSS)

  • polardb: PolarDB

  • petadata: HybridDB for MySQL

  • scdn: Secure CDN (SCDN)

  • sharebandwidthpackages: Internet Shared Bandwidth

  • sls: Log Service

  • vpn: VPN Gateway

Escalations

Map

No

No

The alert settings.

For more information, see Escalations properties.

Period

Integer

No

Yes

The aggregation period of monitoring data.

The default value is the lowest frequency at which the metric is polled. Typically, you do not need to specify the aggregation period.

Unit: seconds.

Webhook

String

No

No

The webhook address to which a request is sent when an alert is triggered.

None.

Namespace

String

Yes

Yes

The namespace of the service.

For more information, see DescribeMetricMetaList or Usage notes.

RuleName

String

Yes

Yes

The name of the alert rule.

None.

Selector

String

No

Yes

The extended field selectors.

None.

Escalations syntax

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

Escalations properties

Property

Type

Required

Editable

Description

Constraint

Critical

Map

Yes

Yes

The settings for critical-level alerts.

For more information, see Critical properties.

Info

Map

No

Yes

The settings for info-level alerts.

For more information, see Info properties.

Warn

Map

No

Yes

The settings for warn-level alerts.

For more information, see Warn properties.

Critical syntax

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

Critical properties

Property

Type

Required

Editable

Description

Constraint

ComparisonOperator

String

Yes

Yes

The comparison operator of the threshold for critical-level alerts.

Valid values:

  • GreaterThanOrEqualToThreshold

  • GreaterThanThreshold

  • LessThanOrEqualToThreshold

  • LessThanThreshold

  • NotEqualToThreshold

  • GreaterThanYesterday

  • LessThanYesterday

  • GreaterThanLastWeek

  • LessThanLastWeek

  • GreaterThanLastPeriod

  • LessThanLastPeriod

Times

Integer

Yes

Yes

The number of times for which the metric value must exceed the threshold consecutively before a critical-level alert is triggered.

None.

Statistics

String

Yes

Yes

The statistical method for critical-level alerts.

None.

Threshold

String

Yes

Yes

The threshold for critical-level alerts.

None.

Info syntax

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

Info properties

Property

Type

Required

Editable

Description

Constraint

ComparisonOperator

String

Yes

Yes

The comparison operator of the threshold for info-level alerts.

Valid values:

  • GreaterThanOrEqualToThreshold

  • GreaterThanThreshold

  • LessThanOrEqualToThreshold

  • LessThanThreshold

  • NotEqualToThreshold

  • GreaterThanYesterday

  • LessThanYesterday

  • GreaterThanLastWeek

  • LessThanLastWeek

  • GreaterThanLastPeriod

  • LessThanLastPeriod

Times

Integer

Yes

Yes

The number of times for which the metric value must exceed the threshold consecutively before an info-level alert is triggered.

None.

Statistics

String

Yes

Yes

The statistical method for info-level alerts.

None.

Threshold

String

Yes

Yes

The threshold for info-level alerts.

None.

Warn syntax

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

Warn properties

Property

Type

Required

Editable

Description

Constraint

ComparisonOperator

String

Yes

Yes

The comparison operator of the threshold for warn-level alerts.

Valid values:

  • GreaterThanOrEqualToThreshold

  • GreaterThanThreshold

  • LessThanOrEqualToThreshold

  • LessThanThreshold

  • NotEqualToThreshold

  • GreaterThanYesterday

  • LessThanYesterday

  • GreaterThanLastWeek

  • LessThanLastWeek

  • GreaterThanLastPeriod

  • LessThanLastPeriod

Times

Integer

Yes

Yes

The number of times for which the metric value must exceed the threshold consecutively before a warn-level alert is triggered.

None.

Statistics

String

Yes

Yes

The statistical method for warn-level alerts.

None.

Threshold

String

Yes

Yes

The threshold for warn-level alerts.

None.

Return values

Fn::GetAtt

Id: the ID of the alert template.

Examples

  • YAML format

    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 monitoring
              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: Disk monitoring
              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 format

    {
      "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 monitoring",
                "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": "Disk monitoring",
                "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"
            ]
          }
        }
      }
    }