Search Alert Rule¶
查询告警规则。
请求格式¶
POST https://{apigw-address}/event-service/v2.1/alert-rules?action=search
请求参数(URI)¶
名称  | 
位置(Path/Query)  | 
必需/可选  | 
数据类型  | 
描述  | 
|---|---|---|---|---|
orgId  | 
Query  | 
必需  | 
String  | 
资产所属的组织 ID。如何获取 orgId 信息>>  | 
请求参数(Body)¶
名称  | 
必需/可选  | 
数据类型  | 
描述  | 
|---|---|---|---|
modelId  | 
可选  | 
String  | 
告警规则适用的模型  | 
measurepointId  | 
可选  | 
String  | 
资产测点。如何获取测点(pointId)信息>>  | 
expression  | 
可选  | 
String  | 
查询表达式,支持类 SQL 的查询。目前支持的逻辑运算是 and 和 or,查询的字段和对应的运算符清单如下。 
  | 
pagination  | 
可选  | 
Pagination 请求结构体  | 
分页的参数。如未指定,默认每页 10 条。支持使用   | 
响应参数¶
名称  | 
数据类型  | 
描述  | 
|---|---|---|
data  | 
AlertRule 结构体  | 
告警规则,见 AlertRule 结构体  | 
AlertRule 结构体  ¶
名称  | 
数据类型  | 
描述  | 
|---|---|---|
orgId  | 
String  | 
规则所属的组织 ID。  | 
ruleId  | 
String  | 
告警规则编号。  | 
ruleDesc  | 
StringI18n  | 
国际化告警描述。  | 
modelId  | 
String  | 
规则适用的模型。  | 
measurepointId  | 
String  | 
资产测点  | 
deviceStatus  | 
String  | 
设备状态。  | 
condition  | 
String  | 
类查询表达式。如“${temperature} = 19”表示“测点 temperature 的值等于 19”。使用“/”表达层级关系,如“${pointA/att1} = 18”表示“测点 A 的 att1 属性值为 18”。目前只支持最多向下一层。  | 
isEnabled  | 
Boolean  | 
是否启用。  | 
severityId  | 
String  | 
告警级别编号。  | 
severityDesc  | 
StringI18n  | 
国际化告警级别描述。  | 
contentId  | 
String  | 
告警内容编号。  | 
contentDesc  | 
StringI18n  | 
国际化告警级别描述。  | 
typeId  | 
String  | 
告警类型  | 
typeDesc  | 
StringI18n  | 
告警类型描述。  | 
tags  | 
Map  | 
规则标签。  | 
isRoot  | 
Boolean  | 
是否是根源告警。  | 
scope  | 
AssetNode 结构体  | 
告警规则的作用域。以资产树上的节点来表示。见 AssetNode 结构体  | 
triggeringDelayTimer  | 
Integer  | 
延后告警触发时间。单位为秒,范围 [60 - 10800]。当发生匹配告警规则的异常状况,且该状况在所设定的时间内仍未恢复正常时,系统才会产生告警。当为 0 时表示立即触发告警。  | 
AssetNode 结构体  ¶
名称  | 
必需/可选  | 
数据类型  | 
描述  | 
|---|---|---|---|
treeId  | 
必需  | 
String  | 
资产树 ID。若为“all”,则这是一个特殊节点,代表组织下的全局。  | 
assetId  | 
必需  | 
String  | 
资产 ID。  | 
示例¶
请求示例¶
url: https://{apigw-address}/event-service/v2.1/alert-rules?action=search&orgId=yourOrgId
method: POST
requestBody:
{
    "modelId": "EnOS_Solar_CombinerBox",
    "measurepointId": "CBX.BranchStateAttr"
}
返回示例¶
{
    "pagination": {
        "pageNo": 1,
        "pageSize": 10,
        "totalSize": 2,
        "sortedBy": [{
            "field": "update_time",
            "order": "DESC"
        }]
    },
    "code": 0,
    "msg": "OK",
    "requestId": "a9689b9f-0cb6-4e47-a41c-bd459b687309",
    "data": [{
        "orgId": "yourOrgId",
        "ruleId": "zh_model_struct",
        "ruleDesc": {
            "defaultValue": "Grid is connected from converter",
            "i18nValue": {
                "en_US": "Grid is connected from converter",
                "zh_CN": "电网由变频器连接"
            }
        },
        "modelId": "zh_model",
        "measurepointId": "aa",
        "condition": "aa = 18",
        "isEnabled": true,
        "severityId": "WARN",
        "severityDesc": {
            "defaultValue": "WARN"
        },
        "contentId": "planetTemperature",
        "contentDesc": {
            "defaultValue": "连接"
        },
        "typeId": "warning_Type",
        "typeDesc": {
            "defaultValue": "connected"
        },
        "tags": {
            "key1": "v1"
        },
        "isRoot": false,
        "scope": [{
            "treeId": "ptde66nd",
            "assetId": "FbFy8qyz"
        }]
    },{
        "orgId": "yourOrgId",
        "ruleId": "zh_model_struct2",
        "ruleDesc": {
            "defaultValue": "Grid is connected from converter",
            "i18nValue": {
                "en_US": "Grid is connected from converter",
                "zh_CN": "电网由变频器连接"
            }
        },
        "modelId": "zh_model",
        "measurepointId": "aa",
        "condition": "aa = 18",
        "isEnabled": true,
        "severityId": "WARN",
        "severityDesc": {
            "defaultValue": "WARN"
        },
        "contentId": "planetTemperature",
        "contentDesc": {
            "defaultValue": "连接"
        },
        "typeId": "warning_Type",
        "typeDesc": {
            "defaultValue": "connected"
        },
        "tags": {
            "key1": "v1"
        },
        "isRoot": false,
        "scope": [{
            "treeId": "ptde66nd",
            "assetId": "FbFy8qyz"
        }]
    }]
}
Java SDK 调用示例¶
public void testSearchAlertRule() {
    private static String accessKey = "yourAppAccessKey";
    private static String secretKey = "yourAppSecretKey";
    private static String orgId = "yourOrgId";
    private static String url = "https://{apigw-address}";
    SearchAlertRuleRequest request = new SearchAlertRuleRequest();
    request.setOrgId(orgId);
    request.setExpression("deviceStatus = 'offline'");
    try {
        SearchAlertRuleResponse response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey).debug())
            .url(url)
            .getResponse(request, SearchAlertRuleResponse.class);
        System.out.println(response);
    } catch (Exception e) {
        System.out.print(e);
    }
}