Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
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
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
IoT
IoT Device Access
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
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
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
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
Domain Name Service
Edge Data Center Management
Meeting
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
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
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
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Creating an Alarm Rule

Updated on 2022-02-22 GMT+08:00

Function

This API is used to create an alarm rule.

URI

POST /V1.0/{project_id}/alarms

  • Parameter description
    Table 1 Parameter description

    Parameter

    Mandatory

    Description

    project_id

    Yes

    Specifies the project ID.

    For details about how to obtain the project ID, see Obtaining a Project ID.

  • Example
    POST https://{Cloud Eye endpoint}/V1.0/{project_id}/alarms

Request

  • Request parameters
    Table 2 Request parameters

    Parameter

    Mandatory

    Type

    Description

    alarm_name

    Yes

    String

    Specifies the alarm rule name.

    The value can contain 1 to 128 characters. Only letters, digits, underscores (_), and hyphens (-) are allowed.

    alarm_description

    No

    String

    Provides supplementary information about the alarm rule. Enter 0 to 256 characters.

    metric

    Yes

    Object

    Specifies the alarm metric.

    For details, see Table 3.

    condition

    Yes

    Object

    Specifies the alarm triggering condition.

    For details, see Table 8.

    alarm_enabled

    No

    Boolean

    Specifies whether to enable the alarm.

    The default value is true.

    alarm_action_enabled

    No

    Boolean

    Specifies whether to enable the action to be triggered by an alarm. The default value is true.

    NOTE:

    If you set alarm_action_enabled to true, you must specify either alarm_actions or ok_actions. (You do not need to configure the deprecated parameter insufficientdata_actions.)

    If alarm_actions and ok_actions coexist, their notificationList values must be the same. (You do not need to configure the deprecated parameter insufficientdata_actions.)

    alarm_level

    No

    Integer

    Specifies the alarm severity. Possible values are 1, 2, 3 and 4, which indicates critical, major, minor, and informational, respectively.

    alarm_actions

    No

    Arrays of objects

    Specifies the action triggered by an alarm.

    An example structure is as follows:

    {

    "type": "notification","notificationList": ["urn:smn:region:68438a86d98e427e907e0097b7e35d47:sd"]

    }

    For details, see Table 5.

    ok_actions

    No

    Arrays of objects

    Specifies the action to be triggered after the alarm is cleared.

    Its structure is:

    { "type": "notification","notificationList": ["urn:smn:region:68438a86d98e427e907e0097b7e35d47:sd"] }

    For details, see Table 6.

    Table 3 metric field data structure description

    Parameter

    Mandatory

    Type

    Description

    namespace

    Yes

    String

    Specifies the namespace of a service. For example, see Namespace for ECS namespace.

    The value must be in the service.item format and can contain 3 to 32 characters. service and item each must be a string that starts with a letter and contains only letters, digits, and underscores (_).

    dimensions

    Yes

    Arrays of objects

    Specifies the list of metric dimensions.

    For details, see Table 4.

    metric_name

    Yes

    String

    Specifies the metric name.

    The value can be a string of 1 to 64 characters, must start with a letter, and contain only letters, digits, and underscores (_).

    For details, see the metric name queried in Querying the Metric List.

    resource_group_id

    No

    String

    Specifies the resource group ID selected during the alarm rule creation, for example, rg1603786526428bWbVmk4rP.

    Table 4 dimensions field data structure description

    Parameter

    Mandatory

    Type

    Description

    name

    No

    String

    Specifies the dimension. For example, the ECS dimension is instance_id, which is listed in the key column in Dimension.

    The value can be a string of 1 to 32 characters, must start with a letter, and contain only letters, digits, underscores (_), and hyphens (-).

    value

    No

    String

    The value can be a string of 1 to 256 characters, must start with a letter or a digit, and contain only letters, digits, underscores (_), and hyphens (-).

    Table 5 alarm_actions field data structure description

    Parameter

    Mandatory

    Type

    Description

    type

    Yes

    String

    Specifies the alarm notification type.
    • notification: indicates that a notification will be sent to the user.
    • autoscaling: indicates that a scaling action will be triggered.

    notificationList

    Yes

    Arrays of strings

    Specifies the list of objects to be notified if the alarm status changes. You can configure a maximum of 5 object IDs. You can obtain the topicUrn value from SMN in the following format: urn:smn:([a-z]|[A-Z]|[0-9]|\-){1,32}:([a-z]|[A-Z]|[0-9]){32}:([a-z]|[A-Z]|[0-9]|\-|\_){1,256}.

    If type is set to notification, the value of notificationList cannot be empty. If type is set to autoscaling, the value of notificationList must be [].

    NOTE:
    • To make the AS alarm rules take effect, you must bind scaling policies. For details, see the Auto Scaling API Reference.
    • If you set alarm_action_enabled to true, you must specify either alarm_actions or ok_actions. (You do not need to configure the deprecated parameter insufficientdata_actions.)
    • If alarm_actions and ok_actions coexist, their notificationList values must be the same. (You do not need to configure the deprecated parameter insufficientdata_actions.)
    • The IDs in the list are character strings.
    Table 6 ok_actions field data structure description

    Parameter

    Mandatory

    Type

    Description

    type

    Yes

    String

    Specifies the notification type when an alarm is triggered.
    • notification: indicates that a notification will be sent to the user.
    • autoscaling: indicates that a scaling action will be triggered.

    notificationList

    Yes

    Arrays of objects

    Specifies the list of objects to be notified if the alarm status changes. You can configure a maximum of 5 object IDs. You can obtain the topicUrn value from SMN in the following format: urn:smn:([a-z]|[A-Z]|[0-9]|\-){1,32}:([a-z]|[A-Z]|[0-9]){32}:([a-z]|[A-Z]|[0-9]|\-|\_){1,256}.

    NOTE:

    If you set alarm_action_enabled to true, you must specify either alarm_actions or ok_actions. (You do not need to configure the deprecated parameter insufficientdata_actions.)

    If alarm_actions and ok_actions coexist, their notificationList values must be the same. (You do not need to configure the deprecated parameter insufficientdata_actions.)

    Table 7 insufficientdata_actions field data structure description

    Parameter

    Mandatory

    Type

    Description

    type

    Yes

    String

    Specifies the notification type when an alarm is triggered.
    • notification: indicates that a notification will be sent to the user.
    • autoscaling: indicates that a scaling action will be triggered.

    notificationList

    Yes

    Arrays of objects

    Specifies the list of objects to be notified if the alarm status changes. You can add up to 5 objects. You can obtain the topicUrn value from SMN in the following format: urn:smn:([a-z]|[A-Z]|[0-9]|\-){1,32}:([a-z]|[A-Z]|[0-9]){32}:([a-z]|[A-Z]|[0-9]|\-|\_){1,256}.

    NOTE:
    • If you set alarm_action_enabled to true, you must specify either alarm_actions or ok_actions. (You do not need to configure the deprecated parameter insufficientdata_actions.)
    • If alarm_actions and ok_actions coexist, their notificationList values must be the same. (You do not need to configure the deprecated parameter insufficientdata_actions.)
    • The IDs in the list are character strings.
    Table 8 condition field data structure description

    Parameter

    Mandatory

    Type

    Description

    period

    Yes

    Integer

    Specifies the period during which Cloud Eye determines whether to trigger an alarm. Unit: second

    Possible values are 1, 300, 1200, 3600, 14400, and 86400.

    NOTE:
    • If you set period to 1, Cloud Eye uses raw data to determine whether to trigger an alarm.

    filter

    Yes

    String

    Specifies the data rollup method.

    Possible values are max, min, average, sum, or variance.

    comparison_operator

    Yes

    String

    Specifies the operator of alarm thresholds.

    Possible values are >, =, <, , and .

    value

    Yes

    Double

    Specifies the alarm threshold.

    The value ranges from 0 to Number. MAX_VALUE (1.7976931348623157e+108).

    For detailed thresholds, see the value range of each metric in the appendix. For example, you can set ECS cpu_util in Metricsto 80.

    unit

    No

    String

    Specifies the data unit. The value contains a maximum of 32 characters.

    count

    Yes

    Integer

    Specifies the number of consecutive occurrence times that the alarm policy was met. The value ranges from 1 to 5.

  • Example request
    {
        "alarm_name": "alarm-rp0E", 
        "alarm_description": "", 
        "metric": {
            "namespace": "SYS.ECS", 
            "dimensions": [
                {
                    "name": "instance_id", 
                    "value": "33328f02-3814-422e-b688-bfdba93d4051"
                }
            ], 
            "metric_name": "network_outgoing_bytes_rate_inband"
        }, 
        "condition": {
            "period": 300, 
            "filter": "average", 
            "comparison_operator": ">=", 
            "value": 6, 
            "unit": "B/s", 
            "count": 1        
       }, 
        "alarm_enabled": true, 
        "alarm_action_enabled": true, 
        "alarm_level": 2,
        "alarm_actions": [
            {
                "type": "notification", 
                "notificationList": ["urn:smn:region:68438a86d98e427e907e0097b7e35d48:sd"]
            }
        ], 
        "ok_actions": [
            {
                "type": "notification", 
                "notificationList": ["urn:smn:region:68438a86d98e427e907e0097b7e35d48:sd"]
            }
        ],
        "insufficientdata_actions": [
            {
                "type": "notification", 
                "notificationList": ["urn:smn:region:68438a86d98e427e907e0097b7e35d48:sd"]
            }
        ]
    }

Response

  • Response parameters
    Table 9 Response parameters

    Parameter

    Type

    Description

    alarm_id

    String

    Specifies the alarm rule ID.

  • Example response
    { 
        "alarm_id":"al1450321795427dR8p5mQBo"
    }

Returned Values

  • Normal

    201

  • Abnormal

    Returned Values

    Description

    400 Bad Request

    Request error.

    401 Unauthorized

    The authentication information is not provided or is incorrect.

    403 Forbidden

    You are forbidden to access the page requested.

    408 Request Timeout

    The request timed out.

    429 Too Many Requests

    Concurrent requests are excessive.

    500 Internal Server Error

    Failed to complete the request because of an internal service error.

    503 Service Unavailable

    The service is currently unavailable.

Error Code

For details, 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

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback