tencent cloud

Feedback

DescribeAlarmPolicies

Last updated: 2022-05-19 11:34:02

1. API Description

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

This API is used to query the list of alarm policies.

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

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 Params. The value used for this API: DescribeAlarmPolicies.
Version Yes String Common Params. The value used for this API: 2018-07-24.
Region Yes String Common Params. For more information, please see the list of regions supported by the product.
Module Yes String Value fixed at "monitor"
PageNumber No Integer Page number starting from 1. Default value: 1
PageSize No Integer Number of entries per page. Value range: 1–100. Default value: 20
PolicyName No String Fuzzy search by policy name
MonitorTypes.N No Array of String Filter by monitor type. Valid values: MT_QCE (Tencent Cloud service monitoring). If this parameter is left empty, all will be queried by default
Namespaces.N No Array of String Filter by namespace. For the values of different policy types, please see:
Policy Type List
Dimensions No String The alarm object list, which is a JSON string. The outer array corresponds to multiple instances, and the inner array is the dimension of an object. For example, “CVM - Basic Monitor” can be written as:
[ {"Dimensions": {"unInstanceId": "ins-qr8d555g"}}, {"Dimensions": {"unInstanceId": "ins-qr8d555h"}} ]
You can also refer to the “Example 2” below.

For more information on the parameter samples of different Tencent Cloud services, see Product Policy Type and Dimension Information.

Note: If 1 is passed in for NeedCorrespondence, the relationship between a policy and an instance needs to be returned. You can pass in up to 20 alarm object dimensions to avoid request timeout.
ReceiverUids.N No Array of Integer Search by recipient. You can get the user list with the API ListUsers in “Cloud Access Management” or query the sub-user information with the API GetUser. The Uid field in the returned result should be entered here.
ReceiverGroups.N No Array of Integer Search by recipient group. You can get the user group list with the API ListGroups in “Cloud Access Management” or query the user group list where a sub-user is in with the API ListGroupsForUser. The GroupId field in the returned result should be entered here.
PolicyType.N No Array of String Filter by default policy. Valid values: DEFAULT (display default policy), NOT_DEFAULT (display non-default policies). If this parameter is left empty, all policies will be displayed
Field No String Sort by field. For example, to sort by the last modification time, use Field: "UpdateTime".
Order No String Sort order. Valid values: ASC (ascending), DESC (descending)
ProjectIds.N No Array of Integer ID array of the policy project, which can be viewed on the following page:
Project Management
NoticeIds.N No Array of String ID list of the notification template, which can be obtained by querying the notification template list.
It can be queried with the API DescribeAlarmNotices.
RuleTypes.N No Array of String Filter by trigger condition. Valid values: STATIC (display policies with static threshold), DYNAMIC (display policies with dynamic threshold). If this parameter is left empty, all policies will be displayed
Enable.N No Array of Integer Filter by alarm status. Valid values: [1]: enabled; [0]: disabled; [0, 1]: all
NotBindingNoticeRule No Integer If 1 is passed in, alarm policies with no notification rules configured are queried. If it is left empty or other values are passed in, all alarm policies are queried.
InstanceGroupId No Integer Instance group ID.
NeedCorrespondence No Integer Whether the relationship between a policy and the input parameter filter dimension is required. 1: Yes. 0: No. Default value: 0.
TriggerTasks.N No Array of AlarmPolicyTriggerTask Filter alarm policy by triggered task (such as auto scaling task). Up to 10 tasks can be specified.
OneClickPolicyType.N No Array of String Filter by quick alarm policy. If this parameter is left empty, all policies are displayed. ONECLICK: Display quick alarm policies; NOT_ONECLICK: Display non-quick alarm policies.

3. Output Parameters

Parameter Name Type Description
TotalCount Integer Total number of policies
Policies Array of AlarmPolicy Policy array
RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Example

Example1 Querying the alarm policy list

Input Example

POST / HTTP/1.1
Host: monitor.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: DescribeAlarmPolicies
<Common request parameters>

{
    "Module": "monitor",
    "PageSize": 10,
    "PageNumber": 1
}

Output Example

{
  "Response": {
    "Policies": [
      {
        "PolicyId": "policy-pvnj4u7h",
        "PolicyName": "Test-2",
        "UseSum": 0,
        "Remark": "For-Test-2",
        "MonitorType": "MT_QCE",
        "Enable": 1,
        "RuleType": "STATIC",
        "TagInstances": null,
        "IsDefault": 0,
        "ProjectId": 0,
        "ProjectName": "",
        "Namespace": "cvm_device",
        "ConditionTemplateId": "",
        "Condition": {
          "IsUnionRule": 0,
          "Rules": [
            {
              "MetricName": "CpuUsage",
              "Description": "CPU utilization",
              "Period": 60,
              "Operator": "gt",
              "Value": "0",
              "ContinuePeriod": 1,
              "NoticeFrequency": 86400,
              "IsPowerNotice": 0,
              "Filter": {
                "Type": "",
                "Dimensions": "[]"
              }
            }
          ]
        },
        "EventCondition": {
          "Rules": []
        },
        "NoticeIds": [
          "notice-esrwma09"
        ],
        "Notices": [
          {
            "Id": "notice-esrwma09",
            "Name": "Notice-Test-2",
            "UpdatedAt": "2020-10-19 20:56:50",
            "UpdatedBy": "1500000685",
            "NoticeType": "OK",
            "UserNotices": [
              {
                "ReceiverType": "GROUP",
                "UserIds": null,
                "GroupIds": [
                  3877
                ],
                "StartTime": 0,
                "EndTime": 1,
                "NoticeWay": [
                  "EMAIL"
                ],
                "PhoneOrder": null,
                "PhoneCircleTimes": 2,
                "PhoneInnerInterval": 60,
                "PhoneCircleInterval": 60,
                "NeedPhoneArriveNotice": 1
              }
            ],
            "URLNotices": [
              {
                "URL": "https://www.abc.com",
                "IsValid": 0
              }
            ],
            "IsPreset": 0
          }
        ],
        "TriggerTasks": [],
        "OriginId": "1314081",
        "ConditionsTemp": {
          "TemplateName": "",
          "Condition": null,
          "EventCondition": null
        },
        "LastEditUin": "1500000685",
        "UpdateTime": 1603114100,
        "InsertTime": 1603114100,
        "Region": [
          "bj",
          "ca",
          "cd",
          "cq",
          "de",
          "fzec",
          "gz",
          "gzopen",
          "hk",
          "hzec",
          "in",
          "jnec",
          "jp",
          "kr",
          "nj",
          "ru",
          "sg",
          "sh",
          "shjr",
          "szjr",
          "szx",
          "th",
          "tpe",
          "tsn",
          "use",
          "usw"
        ],
        "FilterDimensionsParam": "",
        "NamespaceShowName": "CVM - basic monitoring",
        "CanSetDefault": 1,
        "InstanceGroupId": 0,
        "InstanceGroupName": "",
        "InstanceSum": 0
      }
    ],
    "RequestId": "p7gicv4fb-4euztbaaczrsj4vz-s28g-",
    "TotalCount": 1
  }
}

Example2 Searching for an alarm policy associated with a CVM

This example shows you how to filter policies by instance. You need to specify the monitoring/policy type and enter the dimension information of an instance. For example, we will filter policies by searching for two CVMs with the IDs ins-qr8d555g and ins-qr8d555h, respectively.

MonitorTypes is specified as MT_QCE.

Namespaces is specified as cvm_device.

The JSON string specified for Dimensions is

[
    {
        "Dimensions": {
            "unInstanceId": "ins-qr8d555g"
        }
    },
     {
        "Dimensions": {
            "unInstanceId": "ins-qr8d555h"
        }
    }
]

For more information on the parameter samples of different Tencent Cloud services, see Product Policy Type and Dimension Information.

Input Example

POST / HTTP/1.1
Host: monitor.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: DescribeAlarmPolicies
<Common request parameters>

{
    "Module": "monitor",
    "PageSize": 10,
    "PageNumber": 1,
    "MonitorTypes": [
        "MT_QCE"
    ],
    "Namespaces": [
        "cvm_device"
    ],
    "Dimensions": "[{\"Dimensions\": { \"unInstanceId\": \"ins-qr8d555g\"}},{ \"Dimensions\": { \"unInstanceId\": \"ins-qr8d555h\"}}]"
}

Output Example

{
  "Response": {
    "Policies": [
      {
        "PolicyId": "policy-pvnj4u7h",
        "PolicyName": "Test-2",
        "UseSum": 0,
        "Remark": "For-Test-2",
        "MonitorType": "MT_QCE",
        "Enable": 1,
        "RuleType": "STATIC",
        "TagInstances": null,
        "IsDefault": 0,
        "ProjectId": 0,
        "ProjectName": "",
        "Namespace": "cvm_device",
        "ConditionTemplateId": "",
        "Condition": {
          "IsUnionRule": 0,
          "Rules": [
            {
              "MetricName": "CpuUsage",
              "Description": "CPU utilization",
              "Period": 60,
              "Operator": "gt",
              "Value": "0",
              "ContinuePeriod": 1,
              "NoticeFrequency": 86400,
              "IsPowerNotice": 0,
              "Filter": {
                "Type": "",
                "Dimensions": "[]"
              }
            }
          ]
        },
        "EventCondition": {
          "Rules": []
        },
        "NoticeIds": [
          "notice-esrwma09"
        ],
        "Notices": [
          {
            "Id": "notice-esrwma09",
            "Name": "Notice-Test-2",
            "UpdatedAt": "2020-10-19 20:56:50",
            "UpdatedBy": "1500000685",
            "NoticeType": "OK",
            "UserNotices": [
              {
                "ReceiverType": "GROUP",
                "UserIds": null,
                "GroupIds": [
                  3877
                ],
                "StartTime": 0,
                "EndTime": 1,
                "NoticeWay": [
                  "EMAIL"
                ],
                "PhoneOrder": null,
                "PhoneCircleTimes": 2,
                "PhoneInnerInterval": 60,
                "PhoneCircleInterval": 60,
                "NeedPhoneArriveNotice": 1
              }
            ],
            "URLNotices": [
              {
                "URL": "https://www.abc.com",
                "IsValid": 0
              }
            ],
            "IsPreset": 0
          }
        ],
        "TriggerTasks": [],
        "OriginId": "1314081",
        "ConditionsTemp": {
          "TemplateName": "",
          "Condition": null,
          "EventCondition": null
        },
        "LastEditUin": "1500000685",
        "UpdateTime": 1603114100,
        "InsertTime": 1603114100,
        "Region": [
          "bj",
          "ca",
          "cd",
          "cq",
          "de",
          "fzec",
          "gz",
          "gzopen",
          "hk",
          "hzec",
          "in",
          "jnec",
          "jp",
          "kr",
          "nj",
          "ru",
          "sg",
          "sh",
          "shjr",
          "szjr",
          "szx",
          "th",
          "tpe",
          "tsn",
          "use",
          "usw"
        ],
        "FilterDimensionsParam": "",
        "NamespaceShowName": "CVM - basic monitoring",
        "CanSetDefault": 1,
        "InstanceGroupId": 0,
        "InstanceGroupName": "",
        "InstanceSum": 0
      }
    ],
    "RequestId": "p7gicv4fb-4euztbaaczrsj4vz-s28g-",
    "TotalCount": 1
  }
}

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.
UnsupportedOperation Unsupported operation.
Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support