Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Cloud Data Center
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Domain Name Service
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
DataArts Fabric
Cloud Transformation
Well-Architected Framework
Cloud Adoption Framework
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Blockchain
Blockchain Service
Web3 Node Engine Service
MacroVerse aPaaS
CloudDevice
KooDrive
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance (CCI)
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Meeting
IoT
IoT Device Access
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Industry Video Management Service
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
Huawei Cloud Astro Canvas
Huawei Cloud Astro Zero
CodeArts Governance
Help Center/ Cloud Eye/ API Reference/ API V2/ Alarm Templates/ Creating a Custom Alarm Template

Creating a Custom Alarm Template

Function

This API is used to create a custom alarm template.

Debugging

You can debug this API through automatic authentication in API Explorer or use the SDK sample code generated by API Explorer.

URI

POST /v2/{project_id}/alarm-templates

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Tenant ID.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Tenant token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

template_name

Yes

String

Name of an alarm template. The name must start with a letter and can contain 1 to 128 characters, including letters, digits, underscores (_), and hyphens (-).

template_type

No

Integer

Type of a custom alarm template. 0 indicates an alarm template for metrics. 2 indicates an alarm template for events.

Default value:

0

Enumeration values:

  • 0

  • 2

template_description

No

String

Supplementary information about an alarm template. The description can contain 0 to 256 characters and is left blank by default.

is_overwrite

No

Boolean

Whether to overwrite the existing alarm template with the same name. true: Overwrite the alarm template. false: Create a new one.

Default value:

false

policies

Yes

Array of Policies objects

Alarm policies in an alarm template.

Table 4 Policies

Parameter

Mandatory

Type

Description

namespace

Yes

String

Namespace of a service. For details about the namespace of each service, see Namespace.

dimension_name

No

String

Resource dimension, which must start with a letter. A dimension can contain up to 32 characters, including only digits, letters, underscores (_), and hyphens (-). Use commas (,) to separate multiple dimensions. DimensionName in event alarm templates must be left blank.

metric_name

Yes

String

Metric name of a resource. The name must start with a letter and contain only digits, letters, and underscores. The length ranges from 1 to 64 characters. For example, cpu_util of an ECS indicates the CPU usage of the ECS. mongo001_command_ps in DDS indicates the command execution frequency. For details about the metric name of each service, see Service metric name.

extra_info

No

MetricExtraInfo object

Additional information about an alarm policy. This parameter is left blank by default.

period

Yes

Integer

Interval (seconds) for checking whether the alarm rule conditions are met.

Enumeration values:

  • 0

  • 1

  • 300

  • 1200

  • 3600

  • 14400

  • 86400

filter

Yes

String

Aggregation mode. average: average value; variance: variance; min: minimum value; max: maximum value; sum: sum; tp99: 99 percentile; tp95: 95 percentile; tp90: 90 percentile

comparison_operator

Yes

String

Threshold symbol. The value can be >, <, >=, <=, =, !=, cycle_decrease, cycle_increase, or cycle_wave. cycle_decrease indicates the decrease compared with the last period, cycle_increase indicates the increase compared with the last period, and cycle_wave indicates the increase or decrease compared with the last period. All of them can be used in alarm rules for metrics. >, <, >=, <=, =, and != can be used for alarm rules for events.

value

No

Number

Alarm threshold. If there is only one threshold, value and alarm_level are used in pairs. If there are both hierarchical_value and value, hierarchical_value is used.

Value range:

0-1.7976931348623156E108

hierarchical_value

No

HierarchicalValue object

Multi-level alarm threshold. If there are both hierarchical_value and value, hierarchical_value prevails.

When you create or modify an alarm rule, you can set only one threshold in the following scenarios:

  1. The alarm type is Metric and the alarm policy is Trigger an alarm when all policies are met.

  2. The alarm type is Event.

unit

No

String

Data unit. The value can contain up to 32 characters.

selected_unit

No

String

The unit you selected, which is used for subsequent metric data display and calculation.

count

Yes

Integer

Number of consecutive alarm triggering times. For event alarms, the value ranges from 1 to 180. For metric and website alarms, the value can be 1, 2, 3, 4, 5, 10, 15, 30, 60, 90, 120, or 180.

alarm_level

No

Integer

Alarm severity, which can be 1 (critical), ** 2** (major), 3 (minor), or 4 (informational).

suppress_duration

No

Integer

Alarm suppression period, in seconds. When the period is 0, only one alarm is generated.

Enumeration values:

  • 0

  • 300

  • 600

  • 900

  • 1800

  • 3600

  • 10800

  • 21600

  • 43200

  • 86400

Table 5 MetricExtraInfo

Parameter

Mandatory

Type

Description

origin_metric_name

Yes

String

Original metric name.

Regex Pattern: ^([a-z]|[A-Z]|[0-9]|_|-|~|\.|/|:)*$

metric_prefix

No

String

Metric name prefix.

Regex Pattern: ^([a-z]|[A-Z]|[0-9]|_|-|~|\.|/|:)*$

custom_proc_name

No

String

Name of a user process.

metric_type

No

String

Metric type.

Regex Pattern: ^([a-z]|[A-Z]|[0-9]|_|-|~|\.|/|:)*$

Table 6 HierarchicalValue

Parameter

Mandatory

Type

Description

critical

No

Double

Threshold for critical alarms.

Value range:

-1.7976931348623156E108-1.7976931348623156E108

major

No

Double

Threshold for major alarms.

Value range:

-1.7976931348623156E108-1.7976931348623156E108

minor

No

Double

Threshold for minor alarms.

Value range:

-1.7976931348623156E108-1.7976931348623156E108

info

No

Double

Threshold for informational alarms.

Value range:

-1.7976931348623156E108-1.7976931348623156E108

Response Parameters

Status code: 201

Table 7 Response body parameters

Parameter

Type

Description

template_id

String

ID of an alarm template. The ID starts with at and is followed by up to 64 characters, including letters and digits.

Status code: 400

Table 8 Response body parameters

Parameter

Type

Description

error_code

String

Status codes customized by each cloud service when a request error occurs.

error_msg

String

Request error message.

request_id

String

Request ID.

Status code: 401

Table 9 Response body parameters

Parameter

Type

Description

error_code

String

Status codes customized by each cloud service when a request error occurs.

error_msg

String

Request error message.

request_id

String

Request ID.

Status code: 403

Table 10 Response body parameters

Parameter

Type

Description

error_code

String

Status codes customized by each cloud service when a request error occurs.

error_msg

String

Request error message.

request_id

String

Request ID.

Status code: 500

Table 11 Response body parameters

Parameter

Type

Description

error_code

String

Status codes customized by each cloud service when a request error occurs.

error_msg

String

Request error message.

request_id

String

Request ID.

Example Requests

Creating a custom alarm template whose template_name is my_template, count is 2, suppress_duration is 300, and alarm_level is 2.

{
  "template_name" : "my_template",
  "template_description" : "hello world",
  "policies" : [ {
    "namespace" : "SYS.ECS",
    "dimension_name" : "instance_id",
    "metric_name" : "cpu_util",
    "period" : 300,
    "filter" : "sum",
    "comparison_operator" : ">",
    "value" : 2,
    "unit" : "bit/s",
    "count" : 2,
    "alarm_level" : 2,
    "suppress_duration" : 300
  } ]
}

Example Responses

Status code: 201

Created

{
  "template_id" : "at1628592157541dB1klWgY6"
}

Status Codes

Status Code

Description

201

Created

400

Parameter verification failed.

401

Not authenticated.

403

Authentication failed.

500

Internal system error.

Error Codes

See Error Codes.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback
咨询盘古Doer

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback