查询告警规则
接口说明
本文将提供一个示例,查询报警模板列表。返回结果显示,报警模板列表中共有 2 个报警模板,分别是ECS_Template1和ECS_Template2。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
|
操作 |
访问级别 |
资源类型 |
条件关键字 |
关联操作 |
|
cms:QueryAlertRules |
none |
*全部资源
|
无 | 无 |
请求语法
POST /queryAlertRules HTTP/1.1
请求参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| nextToken |
string |
否 |
标记当前开始读取的位置,置空表示从头开始 |
123456 |
| maxResults |
integer |
否 |
本次读取的最大数据记录数量 |
10 |
| clientToken |
string |
否 |
幂等参数 |
xxxxx-xxxx-xxxx |
| body | QueryAlertRulesInput |
否 |
查询告警规则请求 |
|
| queryJson |
string |
否 |
查询过滤条件,JSON 字符串,字段语义与请求体 body 相同:支持 filter(uuid/displayName/labels/status/enabled 等,同级字段之间为 AND 关系)、pagination(pageNumber/pageSize)、workspace。与 body 二选一,两者同时填写时以 body 为准 |
{"filter":{"displayName":{"contains":"my-rule"}},"pagination":{"pageNumber":1,"pageSize":20}} |
返回参数
|
名称 |
类型 |
描述 |
示例值 |
| ServerResponseQueryAlertRulesResult |
查询告警规则响应 |
示例
正常返回示例
JSON格式
{
"code": "200",
"data": {
"alertRules": [
{
"actionIntegrationConfig": {
"actions": [
"xxxx-xxxx-xxxx"
],
"enabled": false
},
"annotations": {
"key": "{'platform': 'github'}\n"
},
"armsIntegrationConfig": {
"enabled": true
},
"bizSource": "示例值",
"conditionConfig": {
"absDeviation": 0,
"aggregate": "AVG",
"alertCount": 1,
"baselinePeriod": "AUTO",
"compareList": [
{
"absDeviation": 0,
"aggregate": "AVG",
"baselinePeriod": "AUTO",
"operator": "OUT_OF_BAND",
"sensitivity": "MEDIUM",
"threshold": 100,
"yoyTimeUnit": "day",
"yoyTimeValue": 1
}
],
"compositeEscalation": {
"escalations": [
{
"absDeviation": 0,
"baselinePeriod": "AUTO",
"comparisonOperator": "GT",
"metricName": "cpuUsage",
"period": 60,
"preCondition": "连续3次",
"sensitivity": "MEDIUM",
"statistics": "Average",
"threshold": "80"
}
],
"relation": "AND",
"severity": "CRITICAL",
"times": 3
},
"countOperator": "GTE",
"countThreshold": 100,
"durationSecs": 60,
"enableSeveritySuppression": true,
"escalationType": "SIMPLE",
"expressEscalation": {
"rawExpression": "cpu_usage > 90",
"severity": "CRITICAL",
"times": 3
},
"legacyRaw": "示例值",
"legacyType": "default",
"matchField": "示例值",
"matchOperator": "PRESENT",
"matchValue": "示例值",
"max": 1,
"min": 1,
"noDataAlertLevel": "INFO",
"noDataAlertSeverity": "INFO",
"noDataAppendValue": 1,
"noDataDurationSecs": 600,
"noDataPolicy": "示例值",
"operator": "GT",
"prometheus": {
"promQl": "rate(http_errors_total[5m]) > 0.1",
"severity": "CRITICAL",
"times": 3
},
"relation": "AND",
"sensitivity": "MEDIUM",
"severity": "INFO",
"simpleEscalation": {
"escalations": [
{
"absDeviation": 0,
"baselinePeriod": "AUTO",
"comparisonOperator": "GT",
"preCondition": "连续3次",
"sensitivity": "MEDIUM",
"severity": "CRITICAL",
"statistics": "Average",
"threshold": "80",
"times": 3
}
],
"metricName": "cpuUsage",
"period": 60
},
"threshold": 30,
"thresholdList": [
{
"max": 100,
"min": 0,
"severity": "CRITICAL",
"threshold": 80
}
],
"triggers": [
{
"comparisonOperator": "示例值",
"condition": "示例值",
"conditions": [
{
"absDeviation": 0,
"baselinePeriod": "AUTO",
"expressionType": "SIMPLE",
"max": 100,
"min": 0,
"operator": "GT",
"queryName": "cpuQuery",
"sensitivity": "MEDIUM",
"threshold": 80
}
],
"countCondition": "示例值",
"countOperator": "GTE",
"countThreshold": 100,
"durationSecs": 1,
"expressionType": "default",
"logicOperator": "AND",
"matchField": "示例值",
"matchOperator": "PRESENT",
"matchValue": "示例值",
"max": 1,
"metricName": "示例名称",
"min": 1,
"operator": "GT",
"period": 1,
"preCondition": "示例值",
"queryName": "示例名称",
"severity": "INFO",
"statistics": "示例值",
"threshold": "90",
"times": 1
}
],
"type": "PROMETHEUS_SIMPLE_CONDITION",
"yoyTimeUnit": "minute",
"yoyTimeValue": 1
},
"contentTemplate": "告警触发: ${metricName} 当前值 ${currentValue} 超过阈值 ${threshold}",
"createdAt": "1751595283143",
"datasourceConfig": {
"instanceId": "rw-xxx",
"legacyRaw": "{\"type\":\"SLS\"}",
"legacyType": "SLS",
"namespace": "selectdb",
"productCategory": "ecs",
"project": "my-project",
"regionId": "cn-hangzhou",
"stores": [
{
"project": "my-sls-project",
"regionId": "cn-hangzhou",
"store": "my-log-store",
"storeType": "LOG"
}
],
"tenantId": "t-xxxxxxx",
"type": "PROMETHEUS"
},
"datasourceType": "default",
"displayName": "CPU水位告警95%",
"enabled": true,
"labels": {
"key": "{'platform': 'github'}"
},
"managedBy": "integrationCenter",
"notifyConfig": {
"activeDays": [
1
],
"activeEndTime": "20:00",
"activeStartTime": "08:00",
"channels": [
{
"identifiers": [
"TEST"
],
"type": "CONTACT"
}
],
"notifyStrategies": [
"example-id-001"
],
"sendRecoverNotification": true,
"severityChannels": {
"key": {
"receivers": [
{
"targetType": "CONTACT",
"identifiers": [
"TEST"
],
"channels": [
"SMS"
]
}
],
"sendRecoverNotification": true
}
},
"silenceTimeSecs": 60,
"type": "DIRECT_NOTIFY",
"utcOffset": "+08:00"
},
"notifyStrategyId": "example-id-001",
"observeResourceConfig": {
"entityDomain": "cloud_monitor",
"entityType": "ACS::ECS::Instance",
"namespace": "acs_ecs_dashboard",
"productCategory": "ecs",
"relationType": "ALL",
"resources": [
"env=prod"
]
},
"observeResourceGlobalScope": true,
"observeResourceList": [
"i-bp1abcxxxxxxxx"
],
"observeResourceType": "default",
"partitionKey": "示例值",
"queryConfig": {
"aggregate": "AVG",
"checkAfterDataComplete": true,
"dimensions": [
{
"key": "i-abc123"
}
],
"durationSecs": 100,
"enableDataCompleteCheck": true,
"entityDomain": "k8s",
"entityFields": [
{
"field": "region",
"value": "cn-hangzhou"
}
],
"entityFilters": [
{
"field": "region",
"operator": "=",
"value": "cn-hangzhou"
}
],
"entityType": "k8s.pod",
"expr": "示例值",
"filterList": [
{
"key": "env",
"type": "ALL",
"value": "prod"
}
],
"filterValues": [
{
"dim": "host",
"opt": "=",
"value": "web-01"
}
],
"groupFieldList": [
"hostName"
],
"groupId": "og-845e0a26455f437c",
"groupType": "default",
"joinings": [
{
"conditions": [
{
"lhsField": "request_id",
"operator": "=",
"rhsField": "trace_id"
}
],
"type": "INNER"
}
],
"labelFilters": [
{
"name": "env",
"operator": "=",
"value": "prod"
}
],
"legacyRaw": "示例值",
"legacyType": "default",
"logSet": "示例名称",
"measureGroupKey": "示例值",
"measureList": [
{
"groupBy": [
"host.name"
],
"measureCode": "cpu_usage",
"windowSecs": 60
}
],
"metric": "node_cpu_seconds_total",
"metricGroupId": "example-id-001",
"metricId": "example-id-001",
"metricIds": [
"upper_normal"
],
"metricSet": "cms.acs_ecs_dashboard.CPUUtilization",
"namespace": "示例名称",
"offsetSecs": 100,
"paramValues": [
{
"name": "threshold",
"value": "80"
}
],
"promQl": "avg(rate(node_cpu_seconds_total{mode=\"idle\"}[5m])) * 100",
"queries": [
{
"end": 100,
"expr": "示例值",
"labelFilters": [
{
"name": "env",
"operator": "=",
"value": "prod"
}
],
"metric": "示例名称",
"metricSet": "示例名称",
"name": "示例名称",
"start": 100,
"timeUnit": "second",
"window": 100
}
],
"relationType": "INSTANCE",
"serviceIdList": [
"xxx-xxx-xxx"
],
"type": "PROMETHEUS_SINGLE_QUERY",
"windowSecs": 100
},
"rcaConfig": {
"enableRca": true,
"digitalEmployeeName": "运维小助手"
},
"regionId": "example-id-001",
"scheduleConfig": {
"intervalSecs": 30,
"type": "FIXED"
},
"severityLevels": "1",
"status": "Alarm",
"updatedAt": "1764556086388",
"uuid": "xxxxx-xxxx-xxxx",
"workspace": "workspace-test"
}
],
"totalCount": 5
},
"message": "The request is invalid.",
"nextToken": "caeba0bbb2be03f84eb48b699f0a4883",
"pageNumber": 1,
"pageSize": 100,
"requestId": "A1B2C3D4-E5F6-7890-ABCD-EF1234567890",
"success": true,
"total": 1
}
错误码
|
HTTP status code |
错误码 |
错误信息 |
描述 |
|---|---|---|---|
| 400 | IdempotentParameterMismatch | The request uses the same client token as a previous, but non-identical request. Do not reuse a client token with different requests, unless the requests are identical. | |
| 400 | InvalidParameter | %s is missing or invalid. | 参数%s缺失或不合法。 |
| 400 | ParameterInvalid | The parameter is missing or invalid. %s | 参数缺失或者参数无效。 |
| 500 | InternalUnknownError | The request processing has failed due to some unknown error. | 服务运行错误。 |
| 403 | Forbidden | You are not authorized to operate the specified resource. | 没有权限,请使用RAM进行授权 |
| 404 | ResourceNotFound | The specified resource is not found. | 未找到指定资源。 |
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。