文档中心>API 中心

查询告警策略列表(支持按实例等条件筛选)

最近更新时间:2024-06-20 01:59:32

我的收藏

1. 接口描述

接口请求域名: monitor.tencentcloudapi.com 。

查询告警策略列表

默认接口请求频率限制:60次/秒。

推荐使用 API Explorer
点击调试
API Explorer 提供了在线调用、签名验证、SDK 代码生成和快速检索接口等能力。您可查看每次调用的请求内容和返回结果以及自动生成 SDK 调用示例。

2. 输入参数

以下请求参数列表仅列出了接口请求参数和部分公共参数,完整公共参数列表见 公共请求参数

参数名称 必选 类型 描述
Action String 公共参数,本接口取值:DescribeAlarmPolicies。
Version String 公共参数,本接口取值:2018-07-24。
Region String 公共参数,此参数为可选参数。
Module String 固定值,为"monitor"
示例值:monitor
PageNumber Integer 页数,从 1 开始计数,默认 1
示例值:1
PageSize Integer 每页的数量,取值1~100,默认20
示例值:20
PolicyName String 按策略名称模糊搜索
示例值:policy-24sxe890
MonitorTypes.N Array of String 根据监控类型过滤 不选默认查所有类型 "MT_QCE"=云产品监控,当Dimension不为空时,该项为必填项
示例值:["MT_QCE"]
Namespaces.N Array of String 根据命名空间过滤,不同策略类型的值详见
策略类型列表当Dimension不为空时,该项为必填项
示例值:["cvm_device"]
Dimensions String 告警对象列表,JSON 字符串。外层数组,对应多个实例,内层为对象的维度。例如“云服务器-基础监控”可写为:
[ {"Dimensions": {"unInstanceId": "ins-qr8d555g"}}, {"Dimensions": {"unInstanceId": "ins-qr8d555h"}} ]
具体也可以参考下方的示例 2。

不同云产品参数示例详见 维度信息Dimensions列表

注意:如果NeedCorrespondence传入1,即需要返回策略与实例对应关系,请传入不多于20个告警对象维度,否则容易请求超时
示例值:[[{"name":"unInstanceId","value":"ins-qr888845g"}]]
ReceiverUids.N Array of Integer 根据接收人搜索,可以使用“访问管理”的 拉取子用户 ListUsers 接口获取用户列表 或 查询子用户 GetUser 接口查询子用户详情,此处填入返回结果中的 Uid 字段
示例值:[9989]
ReceiverGroups.N Array of Integer 根据接收组搜索,可以使用“访问管理”的 查询用户组列表 ListGroups 接口获取用户组列表 或 列出用户关联的用户组 ListGroupsForUser 查询某个子用户所在的用户组列表 ,此处填入返回结果中的 GroupId 字段
示例值:[1112]
PolicyType.N Array of String 根据默认策略筛选 不传展示全部策略 DEFAULT=展示默认策略 NOT_DEFAULT=展示非默认策略
示例值:[DEFAULT]
Field String 排序字段,例如按照最后修改时间排序,Field: "UpdateTime"
示例值:PolicyId
Order String 排序顺序:升序:ASC 降序:DESC
示例值:DESC
ProjectIds.N Array of Integer 策略所属项目的id数组,可在此页面查看
项目管理
示例值:[1]
NoticeIds.N Array of String 通知模板的id列表,可查询通知模板列表获取。
可使用 查询通知模板列表 接口查询。
示例值:[1,2]
RuleTypes.N Array of String 根据触发条件筛选 不传展示全部策略 STATIC=展示静态阈值策略 DYNAMIC=展示动态阈值策略
示例值:[STATIC]
Enable.N Array of Integer 告警启停筛选,[1]:启用 [0]:停止,全部[0, 1]
示例值:1
NotBindingNoticeRule Integer 传 1 查询未配置通知规则的告警策略;不传或传其他数值,查询所有策略。
示例值:1
InstanceGroupId Integer 实例分组id
示例值:1
NeedCorrespondence Integer 是否需要策略与入参过滤维度参数的对应关系,1:是 0:否,默认为0
示例值:1
TriggerTasks.N Array of AlarmPolicyTriggerTask 按照触发任务(例如弹性伸缩)过滤策略。最多10个
OneClickPolicyType.N Array of String 根据一键告警策略筛选 不传展示全部策略 ONECLICK=展示一键告警策略 NOT_ONECLICK=展示非一键告警策略
示例值:["ONECLICK"]
NotBindAll Integer 返回结果过滤掉绑定全部对象的策略,1代表需要过滤,0则无需过滤
示例值:1
NotInstanceGroup Integer 返回结果过滤掉关联实例为实例分组的策略,1代表需要过滤,0则无需过滤
示例值:1
Tags.N Array of Tag 策略根据标签过滤
PromInsId String prom实例id,自定义指标策略时会用到
示例值:prom-xxxx
ReceiverOnCallFormIDs.N Array of String 根据排班表搜索

3. 输出参数

参数名称 类型 描述
TotalCount Integer 策略总数
示例值:100
Policies Array of AlarmPolicy 策略数组
RequestId String 唯一请求 ID,由服务端生成,每次请求都会返回(若请求因其他原因未能抵达服务端,则该次请求不会获得 RequestId)。定位问题时需要提供该次请求的 RequestId。

4. 示例

示例1 根据接收组搜索

根据接收组搜索

输入示例

POST / HTTP/1.1
Host: monitor.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: DescribeAlarmPolicies
<公共请求参数>

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

输出示例

{
    "Response": {
        "TotalCount": 0,
        "Policies": [
            {
                "PolicyId": "abc",
                "PolicyName": "abc",
                "Remark": "abc",
                "MonitorType": "abc",
                "Enable": 0,
                "UseSum": 0,
                "ProjectId": 0,
                "ProjectName": "abc",
                "Namespace": "abc",
                "ConditionTemplateId": "abc",
                "Condition": {
                    "IsUnionRule": 0,
                    "Rules": [
                        {
                            "MetricName": "abc",
                            "Period": 0,
                            "Operator": "abc",
                            "Value": "abc",
                            "ContinuePeriod": 0,
                            "NoticeFrequency": 0,
                            "IsPowerNotice": 0,
                            "Filter": {
                                "Type": "abc",
                                "Dimensions": "abc"
                            },
                            "Description": "abc",
                            "Unit": "abc",
                            "RuleType": "abc",
                            "IsAdvanced": 0,
                            "IsOpen": 0,
                            "ProductId": "abc",
                            "ValueMax": 0,
                            "ValueMin": 0,
                            "HierarchicalValue": {
                                "Remind": "abc",
                                "Warn": "abc",
                                "Serious": "abc"
                            },
                            "IsLatenessMetric": 0
                        }
                    ],
                    "ComplexExpression": "abc"
                },
                "EventCondition": {
                    "Rules": [
                        {
                            "MetricName": "abc",
                            "Period": 0,
                            "Operator": "abc",
                            "Value": "abc",
                            "ContinuePeriod": 0,
                            "NoticeFrequency": 0,
                            "IsPowerNotice": 0,
                            "Filter": {
                                "Type": "abc",
                                "Dimensions": "abc"
                            },
                            "Description": "abc",
                            "Unit": "abc",
                            "RuleType": "abc",
                            "IsAdvanced": 0,
                            "IsOpen": 0,
                            "ProductId": "abc",
                            "ValueMax": 0,
                            "ValueMin": 0,
                            "HierarchicalValue": {
                                "Remind": "abc",
                                "Warn": "abc",
                                "Serious": "abc"
                            },
                            "IsLatenessMetric": 0
                        }
                    ]
                },
                "NoticeIds": [
                    "abc"
                ],
                "Notices": [
                    {
                        "Id": "abc",
                        "Name": "abc",
                        "UpdatedAt": "abc",
                        "UpdatedBy": "abc",
                        "NoticeType": "abc",
                        "UserNotices": [
                            {
                                "ReceiverType": "abc",
                                "UserIds": [
                                    0
                                ],
                                "GroupIds": [
                                    0
                                ],
                                "StartTime": 0,
                                "EndTime": 0,
                                "NoticeWay": [
                                    "abc"
                                ],
                                "PhoneOrder": [
                                    0
                                ],
                                "PhoneCircleTimes": 0,
                                "PhoneInnerInterval": 0,
                                "PhoneCircleInterval": 0,
                                "NeedPhoneArriveNotice": 0,
                                "PhoneCallType": "abc",
                                "Weekday": [
                                    0
                                ],
                                "OnCallFormIDs": [
                                    "abc"
                                ]
                            }
                        ],
                        "URLNotices": [
                            {
                                "URL": "abc",
                                "IsValid": 0,
                                "ValidationCode": "abc",
                                "StartTime": 0,
                                "EndTime": 0,
                                "Weekday": [
                                    0
                                ]
                            }
                        ],
                        "IsPreset": 0,
                        "NoticeLanguage": "abc",
                        "PolicyIds": [
                            "abc"
                        ],
                        "AMPConsumerId": "abc",
                        "CLSNotices": [
                            {
                                "Enable": 0,
                                "Region": "abc",
                                "LogSetId": "abc",
                                "TopicId": "abc"
                            }
                        ],
                        "Tags": [
                            {
                                "Key": "abc",
                                "Value": "abc"
                            }
                        ]
                    }
                ],
                "TriggerTasks": [
                    {
                        "Type": "abc",
                        "TaskConfig": "abc"
                    }
                ],
                "ConditionsTemp": {
                    "TemplateName": "abc",
                    "Condition": {
                        "IsUnionRule": 0,
                        "Rules": [
                            {
                                "MetricName": "abc",
                                "Period": 0,
                                "Operator": "abc",
                                "Value": "abc",
                                "ContinuePeriod": 0,
                                "NoticeFrequency": 0,
                                "IsPowerNotice": 0,
                                "Filter": {
                                    "Type": "abc",
                                    "Dimensions": "abc"
                                },
                                "Description": "abc",
                                "Unit": "abc",
                                "RuleType": "abc",
                                "IsAdvanced": 0,
                                "IsOpen": 0,
                                "ProductId": "abc",
                                "ValueMax": 0,
                                "ValueMin": 0,
                                "HierarchicalValue": {
                                    "Remind": "abc",
                                    "Warn": "abc",
                                    "Serious": "abc"
                                },
                                "IsLatenessMetric": 0
                            }
                        ],
                        "ComplexExpression": "abc"
                    },
                    "EventCondition": {}
                },
                "LastEditUin": "abc",
                "UpdateTime": 0,
                "InsertTime": 0,
                "Region": [
                    "abc"
                ],
                "NamespaceShowName": "abc",
                "IsDefault": 0,
                "CanSetDefault": 0,
                "InstanceGroupId": 0,
                "InstanceSum": 0,
                "InstanceGroupName": "abc",
                "RuleType": "abc",
                "OriginId": "abc",
                "TagInstances": [
                    {
                        "Key": "abc",
                        "Value": "abc",
                        "InstanceSum": 0,
                        "ServiceType": "abc",
                        "RegionId": 0,
                        "BindingStatus": 0,
                        "TagStatus": 0
                    }
                ],
                "Filter": {
                    "Type": "abc",
                    "Expression": "abc",
                    "Dimensions": "abc"
                },
                "GroupBy": [
                    {
                        "Id": "abc",
                        "Name": "abc"
                    }
                ],
                "FilterDimensionsParam": "abc",
                "IsOneClick": 0,
                "OneClickStatus": 0,
                "AdvancedMetricNumber": 0,
                "IsBindAll": 0,
                "Tags": [
                    {
                        "Key": "abc",
                        "Value": "abc"
                    }
                ],
                "IsSupportAlarmTag": 0,
                "TagOperation": "abc"
            }
        ],
        "RequestId": "abc"
    }
}

示例2 搜索一个云服务器绑定的告警策略

按照实例过滤策略,需要填入监控类型、策略类型、实例的维度信息。我们以搜索两个云服务器为例,假设他们的实例 ID 分别为 ins-qr8d555g, ins-qr8d555h

MonitorTypes 指定为 MT_QCE

Namespaces 指定为 cvm_device

Dimensions 的 JSON 字符串为

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

不同云产品参数示例详见 维度信息Dimensions列表

输入示例

POST / HTTP/1.1
Host: monitor.tencentcloudapi.com
Content-Type: application/json
X-TC-Action: DescribeAlarmPolicies
<公共请求参数>

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

输出示例

{
    "Response": {
        "TotalCount": 0,
        "Policies": [
            {
                "PolicyId": "abc",
                "PolicyName": "abc",
                "Remark": "abc",
                "MonitorType": "abc",
                "Enable": 0,
                "UseSum": 0,
                "ProjectId": 0,
                "ProjectName": "abc",
                "Namespace": "abc",
                "ConditionTemplateId": "abc",
                "Condition": {
                    "IsUnionRule": 0,
                    "Rules": [
                        {
                            "MetricName": "abc",
                            "Period": 0,
                            "Operator": "abc",
                            "Value": "abc",
                            "ContinuePeriod": 0,
                            "NoticeFrequency": 0,
                            "IsPowerNotice": 0,
                            "Filter": {
                                "Type": "abc",
                                "Dimensions": "abc"
                            },
                            "Description": "abc",
                            "Unit": "abc",
                            "RuleType": "abc",
                            "IsAdvanced": 0,
                            "IsOpen": 0,
                            "ProductId": "abc",
                            "ValueMax": 0,
                            "ValueMin": 0,
                            "HierarchicalValue": {
                                "Remind": "abc",
                                "Warn": "abc",
                                "Serious": "abc"
                            },
                            "IsLatenessMetric": 0
                        }
                    ],
                    "ComplexExpression": "abc"
                },
                "EventCondition": {
                    "Rules": [
                        {
                            "MetricName": "abc",
                            "Period": 0,
                            "Operator": "abc",
                            "Value": "abc",
                            "ContinuePeriod": 0,
                            "NoticeFrequency": 0,
                            "IsPowerNotice": 0,
                            "Filter": {
                                "Type": "abc",
                                "Dimensions": "abc"
                            },
                            "Description": "abc",
                            "Unit": "abc",
                            "RuleType": "abc",
                            "IsAdvanced": 0,
                            "IsOpen": 0,
                            "ProductId": "abc",
                            "ValueMax": 0,
                            "ValueMin": 0,
                            "HierarchicalValue": {
                                "Remind": "abc",
                                "Warn": "abc",
                                "Serious": "abc"
                            },
                            "IsLatenessMetric": 0
                        }
                    ]
                },
                "NoticeIds": [
                    "abc"
                ],
                "Notices": [
                    {
                        "Id": "abc",
                        "Name": "abc",
                        "UpdatedAt": "abc",
                        "UpdatedBy": "abc",
                        "NoticeType": "abc",
                        "UserNotices": [
                            {
                                "ReceiverType": "abc",
                                "UserIds": [
                                    0
                                ],
                                "GroupIds": [
                                    0
                                ],
                                "StartTime": 0,
                                "EndTime": 0,
                                "NoticeWay": [
                                    "abc"
                                ],
                                "PhoneOrder": [
                                    0
                                ],
                                "PhoneCircleTimes": 0,
                                "PhoneInnerInterval": 0,
                                "PhoneCircleInterval": 0,
                                "NeedPhoneArriveNotice": 0,
                                "PhoneCallType": "abc",
                                "Weekday": [
                                    0
                                ],
                                "OnCallFormIDs": [
                                    "abc"
                                ]
                            }
                        ],
                        "URLNotices": [
                            {
                                "URL": "abc",
                                "IsValid": 0,
                                "ValidationCode": "abc",
                                "StartTime": 0,
                                "EndTime": 0,
                                "Weekday": [
                                    0
                                ]
                            }
                        ],
                        "IsPreset": 0,
                        "NoticeLanguage": "abc",
                        "PolicyIds": [
                            "abc"
                        ],
                        "AMPConsumerId": "abc",
                        "CLSNotices": [
                            {
                                "Enable": 0,
                                "Region": "abc",
                                "LogSetId": "abc",
                                "TopicId": "abc"
                            }
                        ],
                        "Tags": [
                            {
                                "Key": "abc",
                                "Value": "abc"
                            }
                        ]
                    }
                ],
                "TriggerTasks": [
                    {
                        "Type": "abc",
                        "TaskConfig": "abc"
                    }
                ],
                "ConditionsTemp": {
                    "TemplateName": "abc",
                    "Condition": {
                        "IsUnionRule": 0,
                        "Rules": [
                            {
                                "MetricName": "abc",
                                "Period": 0,
                                "Operator": "abc",
                                "Value": "abc",
                                "ContinuePeriod": 0,
                                "NoticeFrequency": 0,
                                "IsPowerNotice": 0,
                                "Filter": {
                                    "Type": "abc",
                                    "Dimensions": "abc"
                                },
                                "Description": "abc",
                                "Unit": "abc",
                                "RuleType": "abc",
                                "IsAdvanced": 0,
                                "IsOpen": 0,
                                "ProductId": "abc",
                                "ValueMax": 0,
                                "ValueMin": 0,
                                "HierarchicalValue": {
                                    "Remind": "abc",
                                    "Warn": "abc",
                                    "Serious": "abc"
                                },
                                "IsLatenessMetric": 0
                            }
                        ],
                        "ComplexExpression": "abc"
                    },
                    "EventCondition": {}
                },
                "LastEditUin": "abc",
                "UpdateTime": 0,
                "InsertTime": 0,
                "Region": [
                    "abc"
                ],
                "NamespaceShowName": "abc",
                "IsDefault": 0,
                "CanSetDefault": 0,
                "InstanceGroupId": 0,
                "InstanceSum": 0,
                "InstanceGroupName": "abc",
                "RuleType": "abc",
                "OriginId": "abc",
                "TagInstances": [
                    {
                        "Key": "abc",
                        "Value": "abc",
                        "InstanceSum": 0,
                        "ServiceType": "abc",
                        "RegionId": 0,
                        "BindingStatus": 0,
                        "TagStatus": 0
                    }
                ],
                "Filter": {
                    "Type": "abc",
                    "Expression": "abc",
                    "Dimensions": "abc"
                },
                "GroupBy": [
                    {
                        "Id": "abc",
                        "Name": "abc"
                    }
                ],
                "FilterDimensionsParam": "abc",
                "IsOneClick": 0,
                "OneClickStatus": 0,
                "AdvancedMetricNumber": 0,
                "IsBindAll": 0,
                "Tags": [
                    {
                        "Key": "abc",
                        "Value": "abc"
                    }
                ],
                "IsSupportAlarmTag": 0,
                "TagOperation": "abc"
            }
        ],
        "RequestId": "abc"
    }
}

5. 开发者资源

腾讯云 API 平台

腾讯云 API 平台 是综合 API 文档、错误码、API Explorer 及 SDK 等资源的统一查询平台,方便您从同一入口查询及使用腾讯云提供的所有 API 服务。

API Inspector

用户可通过 API Inspector 查看控制台每一步操作关联的 API 调用情况,并自动生成各语言版本的 API 代码,也可前往 API Explorer 进行在线调试。

SDK

云 API 3.0 提供了配套的开发工具集(SDK),支持多种编程语言,能更方便的调用 API。

命令行工具

6. 错误码

以下仅列出了接口业务逻辑相关的错误码,其他错误码详见 公共错误码

错误码 描述
FailedOperation 操作失败。
FailedOperation.DoHTTPTransferFailed 后端服务超时
InternalError 内部错误。
UnsupportedOperation 操作不支持。