CreateAlarmPolicy

Last updated: 2021-04-20 17:03:07

    1. API Description

    Domain name for API request: monitor.tencentcloudapi.com.

    This API is used to create an alarm policy.

    A maximum of 20 requests can be initiated per second for this API.

    Note: This API supports Finance regions. If the common parameter Region is a Finance region, a domain name with the Finance region needs to be specified, for example: monitor.ap-shanghai-fsi.tencentcloudapi.com

    We recommend you to use API Explorer
    Try it
    API Explorer provides a range of capabilities, including online call, signature authentication, SDK code generation, and API quick search. It enables you to view the request, response, and auto-generated examples.

    2. Input Parameters

    The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

    Parameter Name Required Type Description
    Action Yes String Common parameter. The value used for this API: CreateAlarmPolicy.
    Version Yes String Common parameter. The value used for this API: 2018-07-24.
    Region Yes String Common parameter. For more information, please see the list of regions supported by the product.
    Module Yes String Value fixed at "monitor"
    PolicyName Yes String Policy name, which can contain up to 20 characters
    MonitorType Yes String Monitor type. Valid values: MT_QCE (Tencent Cloud service monitoring)
    Namespace Yes String Type of alarm policy, which can be obtained via DescribeAllNamespaces. An example value is cvm_device.
    Remark No String Remarks with up to 100 letters, digits, underscores, and hyphens
    Enable No Integer Whether to enable. Valid values: 0 (no), 1 (yes). Default value: 1. This parameter can be left empty
    ProjectId No Integer Project ID. For products with different projects, a value other than -1 must be passed in. -1: no project; 0: default project. If no value is passed in, -1 will be used. The supported project IDs can be viewed on the Account Center > Project Management page of the console.
    ConditionTemplateId No Integer ID of trigger condition template. This parameter can be left empty.
    Condition No AlarmPolicyCondition Metric trigger condition. The supported metrics can be queried via DescribeAlarmMetrics.
    EventCondition No AlarmPolicyEventCondition Event trigger condition. The supported events can be queried via DescribeAlarmEvents.
    NoticeIds.N No Array of String List of notification rule IDs, which can be obtained via DescribeAlarmNotices
    TriggerTasks.N No Array of AlarmPolicyTriggerTask Triggered task list

    3. Output Parameters

    Parameter Name Type Description
    PolicyId String Alarm policy ID
    OriginId String Alarm policy ID, which can be used when you call APIs (BindingPolicyObject, UnBindingAllPolicyObject, UnBindingPolicyObject) to bind/unbind instances or instance groups to/from an alarm policy
    RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

    4. Example

    Example1 Creating alarm policy

    This example shows you how to bind two notification rules and one auto scaling policy where the policy type is "CVM - basic monitoring", triggering metric is "CPU utilization >= 99.9%", and triggering event is "unreachable by ping".

    Input Example

    POST / HTTP/1.1
    Host: monitor.tencentcloudapi.com
    Content-Type: application/json
    X-TC-Action: CreateAlarmPolicy
    <Common request parameters>
    
    {
        "Module": "monitor",
        "PolicyName": "CVM alarm policy",
        "Remark": "This is the remark",
        "MonitorType": "MT_QCE",
        "Enable": 1,
        "ProjectId": 0,
        "Namespace": "cvm_device",
        "Condition": {
            "IsUnionRule": 1,
            "Rules": [
                {
                    "MetricName": "cpu_usage",
                    "Period": 60,
                    "Operator": "ge",
                    "Value": "99.9",
                    "ContinuePeriod": 1,
                    "NoticeFrequency": 3600,
                    "IsPowerNotice": 0
                }
            ]
        },
        "EventCondition": {
            "Rules": [
                {
                    "MetricName": "ping_unreach"
                }
            ]
        },
        "NoticeIds": [
            "notice-bv9b4ghqbg",
            "notice-gj2n9wnt29"
        ],
        "TriggerTasks": [
            {
                "Type": "AS",
                "TaskConfig": "{\"Region\":\"ap-guangzhou\",\"Group\":\"asg-0zhspjx\",\"Policy\":\"asp-ganig28\"}"
            }
        ]
    }
    

    Output Example

    {
      "Response": {
        "RequestId": "29ghj2hh-45-h53h234h-23",
        "PolicyId": "policy-hi498gw3h2",
        "OriginId": "1234556"
      }
    }
    

    5. Developer Resources

    SDK

    TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

    Command Line Interface

    6. Error Code

    The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

    Error Code Description
    FailedOperation Operation failed.
    InternalError Internal error.
    InvalidParameter Invalid parameter.
    InvalidParameterValue The parameter value is incorrect.
    LimitExceeded Quota limit is reached.
    ResourceNotFound The resource is not found.
    UnsupportedOperation Unsupported operation.

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback
    Help