All Products
Search
Document Center

Resource Orchestration Service:ALIYUN::CMS::MetricRuleTemplate

Last Updated:Oct 25, 2024

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

Syntax

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

Properties

Property

Type

Required

Editable

Description

Constraint

Name

String

Yes

No

The name of the alert rule template.

None.

AlertTemplates

List

No

Yes

Details of the alert rule template.

You can specify up to 200 alert rules in an alert rule template.

For more information, see AlertTemplates properties.

Description

String

No

Yes

The description of the alert rule template.

None.

RestVersion

Integer

No

No

The version of the alert rule template.

Default value: 0.

TemplateId

Integer

No

No

The ID of the template that you want to clone.

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

Category

String

Yes

Yes

The abbreviation of the service name or feature.

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 Content Delivery Network (DCDN)

  • ddos: Anti-DDoS Proxy

  • eip: Elastic IP Address (EIP)

  • elasticsearch: Elasticsearch

  • emr: E-MapReduce (EMR)

  • ess: Auto Scaling

  • hbase: ApsaraDB for HBase

  • iot_edge: Link IoT Edge

  • k8s_pod: ACK pod

  • kvstore_sharding: Tair (Redis OSS-compatible) of the cluster architecture

  • kvstore_splitrw: Tair (Redis OSS-compatible) of the read/write splitting architecture

  • kvstore_standard: Tair (Redis OSS-compatible) of the standard architecture

  • memcache: ApsaraDB for Memcache (OCS, New Version)

  • smq: Simple Message Queue (formerly MNS) (SMQ)

  • mongodb: ApsaraDB for MongoDB replica set instance

  • mongodb_cluster: ApsaraDB for MongoDB standalone instance

  • mongodb_sharding: ApsaraDB for MongoDB sharded cluster instance

  • mq_topic: SMQ topic

  • ocs: ApsaraDB for Memcache (OCS, Old Version)

  • opensearch: OpenSearch

  • oss: Object Storage Service (OSS)

  • polardb: PolarDB

  • petadata: HybridDB for MySQL

  • scdn: Secure CDN (SCDN)

  • sharebandwidthpackages: Internet Shared Bandwidth

  • sls: Simple Log Service (SLS)

  • vpn: VPN Gateway

MetricName

String

Yes

Yes

The name of the metric.

None.

Namespace

String

Yes

Yes

The namespace of the cloud service.

For more information, see DescribeMetricMetaList or Usage notes.

RuleName

String

Yes

Yes

The name of the alert rule.

None.

Escalations

Map

No

No

The alert settings.

For more information, see Escalations properties.

Period

Integer

No

Yes

The aggregation period of the metric data.

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

Unit: seconds.

Selector

String

No

Yes

The extended field selector.

None.

Webhook

String

No

No

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

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.

Valid values:

  • GreaterThanOrEqualToThreshold: greater than or equal to the threshold.

  • GreaterThanThreshold: greater than the threshold.

  • LessThanOrEqualToThreshold: less than or equal to the threshold.

  • LessThanThreshold: less than the threshold.

  • NotEqualToThreshold: not equal to the threshold.

  • GreaterThanYesterday: greater than the metric value at the same time yesterday.

  • LessThanYesterday: less than the metric value at the same time yesterday.

  • GreaterThanLastWeek: greater than the metric value at the same time last week.

  • LessThanLastWeek: less than the metric value at the same time last week.

  • GreaterThanLastPeriod: greater than the metric value in the previous monitoring cycle.

  • LessThanLastPeriod: less than the metric value in the previous monitoring cycle.

Statistics

String

Yes

Yes

The method used to calculate the metric value based on which alerts are triggered.

None.

Threshold

String

Yes

Yes

The alert threshold.

None.

Times

Integer

Yes

Yes

The consecutive number of times for which the metric value meets the alert condition before an alert is triggered.

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.

Valid values:

  • GreaterThanOrEqualToThreshold: greater than or equal to the threshold.

  • GreaterThanThreshold: greater than the threshold.

  • LessThanOrEqualToThreshold: less than or equal to the threshold.

  • LessThanThreshold: less than the threshold.

  • NotEqualToThreshold: not equal to the threshold.

  • GreaterThanYesterday: greater than the metric value at the same time yesterday.

  • LessThanYesterday: less than the metric value at the same time yesterday.

  • GreaterThanLastWeek: greater than the metric value at the same time last week.

  • LessThanLastWeek: less than the metric value at the same time last week.

  • GreaterThanLastPeriod: greater than the metric value in the previous monitoring cycle.

  • LessThanLastPeriod: less than the metric value in the previous monitoring cycle.

Statistics

String

Yes

Yes

The method used to calculate the metric value based on which alerts are triggered.

None.

Threshold

String

Yes

Yes

The alert threshold.

None.

Times

Integer

Yes

Yes

The consecutive number of times for which the metric value meets the alert condition before an alert is triggered.

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.

Valid values:

  • GreaterThanOrEqualToThreshold: greater than or equal to the threshold.

  • GreaterThanThreshold: greater than the threshold.

  • LessThanOrEqualToThreshold: less than or equal to the threshold.

  • LessThanThreshold: less than the threshold.

  • NotEqualToThreshold: not equal to the threshold.

  • GreaterThanYesterday: greater than the metric value at the same time yesterday.

  • LessThanYesterday: less than the metric value at the same time yesterday.

  • GreaterThanLastWeek: greater than the metric value at the same time last week.

  • LessThanLastWeek: less than the metric value at the same time last week.

  • GreaterThanLastPeriod: greater than the metric value in the previous monitoring cycle.

  • LessThanLastPeriod: less than the metric value in the previous monitoring cycle.

Statistics

String

Yes

Yes

The method used to calculate the metric value based on which alerts are triggered.

None.

Threshold

String

Yes

Yes

The alert threshold.

None.

Times

Integer

Yes

Yes

The consecutive number of times for which the metric value meets the alert condition before an alert is triggered.

None.

Return values

Fn::GetAtt

Id: the ID of the alert rule template.

Examples

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

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