Search History Alerts¶
查询最近三个月内的历史告警。
请求格式¶
POST https://{apigw-address}/event-service/v2.1/history-alerts?action=search
请求参数(URI)¶
名称  | 
位置(Path/Query)  | 
必需/可选  | 
数据类型  | 
描述  | 
|---|---|---|---|---|
orgId  | 
Query  | 
必需  | 
String  | 
资产所属的组织 ID。如何获取 orgId 信息>>  | 
请求参数(Body)¶
名称  | 
必需/可选  | 
数据类型  | 
描述  | 
|---|---|---|---|
modelId  | 
可选  | 
String  | 
资产所属模型 ID。如何获取 modelId 信息>>  | 
assetId  | 
可选  | 
String  | 
资产 ID。如何获取 assetId 信息>>  | 
measurepointsId  | 
可选  | 
String  | 
资产测点 ID。如何获取测点(pointId)信息>>  | 
startOccurTime  | 
必需  | 
String  | 
查询起始时间,与   | 
endOccurTime  | 
必需  | 
String  | 
查询结束时间,与   | 
recoverStartTime  | 
可选  | 
String  | 
查询起始时间,与   | 
recoverEndTime  | 
可选  | 
String  | 
查询起始时间,与   | 
expression  | 
可选  | 
String  | 
查询表达式,支持类 SQL 的查询。目前支持的逻辑运算是 and 和 or,查询的字段和对应的运算符清单如下。 
  | 
scope  | 
可选  | 
Scope 结构体  | 
查询指定资产树或资产树上某资产节点下的告警,并指定是否返回被屏蔽的衍生告警。该参数不可与 rootAlert 参数同时使用。见 Scope 结构体  | 
rootAlert  | 
可选  | 
RootAlert 结构体  | 
查询被指定根源告警屏蔽的衍生告警。该参数不可与 scope 参数同时使用。见 RootAlert 结构体  | 
pagination  | 
可选  | 
Pagination 请求结构体  | 
随机分页。不支持使用   | 
Scope 结构体  ¶
名称  | 
必需/可选  | 
数据类型  | 
描述  | 
|---|---|---|---|
treeId  | 
必需  | 
String  | 
资产树 ID。  | 
fromAssetId  | 
可选  | 
String  | 
  | 
includeDerivative  | 
可选  | 
Boolean  | 
是否返回衍生告警,默认为   | 
RootAlert 结构体  ¶
名称  | 
必需/可选  | 
数据类型  | 
描述  | 
|---|---|---|---|
treeId  | 
可选  | 
String  | 
资产树 ID。  | 
rootAlertId  | 
必需  | 
String  | 
根源告警 ID。  | 
响应参数¶
名称  | 
数据类型  | 
描述  | 
|---|---|---|
data  | 
HistoryAler t结构体数组  | 
有关 HistoryAlert 结构体的定义。见 HistoryAlert 结构体>>  | 
HistoryAlert 结构体¶
名称  | 
数据类型  | 
描述  | 
|---|---|---|
eventId  | 
String  | 
告警 ID。  | 
orgId  | 
String  | 
资产所属的组织 ID。  | 
assetId  | 
String  | 
资产ID。  | 
modelId  | 
String  | 
资产所属模型 ID。  | 
modelIdPath  | 
String  | 
模型所属路径。  | 
measurepointId  | 
String  | 
资产测点。  | 
deviceStatus  | 
String  | 
设备状态。  | 
hitRuleId  | 
String  | 
触发的告警规则的编号。  | 
value  | 
Integer/Double/Struct  | 
测点值。其类型根据模型的功能定义而确定。若告警规则中指定了   | 
occurTime  | 
Long  | 
告警发生的时间,以 UTC 时间表示。  | 
localOccurTime  | 
String  | 
告警发生的时间,以本地时间表示。  | 
recoverTime  | 
Long  | 
触发告警的异常状况恢复正常的时间,以 UTC 时间表示。  | 
localRecoverTime  | 
String  | 
触发告警的异常状况恢复正常的时间,以本地时间表示。  | 
recoverReason  | 
String  | 
异常状况恢复的原因。  | 
createTime  | 
Long  | 
该告警记录的入库时间,以 UTC 时间表示。  | 
updateTime  | 
Long  | 
该告警记录的更新时间,以 UTC 时间表示。  | 
severityId  | 
String  | 
告警级别标识符。  | 
severityDesc  | 
StringI18n  | 
告警级别描述。见 国际化名称结构体>>  | 
typeId  | 
String  | 
告警类别标识符。  | 
typeDesc  | 
StringI18n  | 
告警类型的具体描述。见 国际化名称结构体>>  | 
subTypeId  | 
String  | 
告警子类型。  | 
subTypeDesc  | 
StringI18n  | 
告警子类型描述。见 国际化名称结构体>>  | 
contentId  | 
String  | 
告警内容标识符。  | 
contentDesc  | 
StringI18n  | 
告警内容描述。见 国际化名称结构体>>  | 
eventType  | 
Integer  | 
事件类型: 0:系统恢复的告警;1:系统触发的告警;2:通过API恢复的告警;3:通过API插入的告警。  | 
tag  | 
Map  | 
告警记录标签。详见 标签的作用与表示方法>>  | 
ruleDesc  | 
StringI18n  | 
规则描述。见 国际化名称结构体>>  | 
assetPaths  | 
String 数组  | 
根据告警规则的作用域,返回告警资产在资产树上的路径列表。返回格式为:[“treeId1:/assetId1/assetId2/assetIdx”, “treeId2:/assetId3/assetIdx”]。  | 
maskedBy  | 
String 数组  | 
如果该告警条目是衍生告警,返回导致该告警被屏蔽的根源告警信息。返回格式为:[“treeId1:eventId1”, “treeId1:eventId2”]。  | 
示例¶
请求示例¶
url: https://{apigw-address}/event-service/v2.1/history-alerts?action=search&orgId=yourOrgId
method: POST
requestBody:
{
    "endOccurTime": "2019-06-15T00:00:00Z",
    "expression": "eventId='20190612cf89cd96b0be4cafcc342d0dc2ac75a4'",
    "pagination": {
        "pageNo": 1,
        "pageSize": 2
    },
    "startOccurTime": "2019-05-20T00:00:00Z",
  "action": "search"
}
返回示例¶
{
    "pagination":{
        "pageNo":1,
        "pageSize":2,
        "totalSize":1,
        "sortedBy":[
            {
                "field":"occurTime",
                "order":"DESC"
            },
            {
                "field":"eventId",
                "order":"DESC"
            }
        ]
    },
    "code":0,
    "msg":"OK",
    "requestId":"dac2a872-b9b7-460c-992d-0a0c14ea36e9",
    "data":[
        {
            "recoverTime":1560382560000,
            "recoverLocalTime":"2019-06-13 07:36:00",
            "recoverReason":"rule-recover",
            "eventId":"20190612cf89cd96b0be4cafcc342d0dc2ac75a4",
            "orgId":"yourOrgId",
            "assetId":"rQN8IRs4",
            "modelId":"lemo2",
            "modelIdPath":"/lemo2",
            "measurepointId":"lemo_point1_raw",
            "value":"99.06250421",
            "occurTime":1560382380000,
            "localOccurTime":"2019-06-13 07:33:00",
            "createTime":1560382559735,
            "updateTime":1560744923855,
            "severityId":"Urgent",
      "deviceStatus":null,
      "subTypeId":null,
      "subTypeDesc":null,
      "ruleDesc":null,
      "assetPath":null,
      "maskedBy":null,
            "severityDesc":{
                "i18nValue":{
                    "en_US":"紧急告警",
                    "zh_CN":"紧急告警"
                }
            },
            "typeId":"yourTypeId",
            "typeDesc":{
                "i18nValue":{
                    "en_US":"yourAlertType",
                    "zh_CN":"yourAlertTypeInChinese"
                }
            },
            "contentId":"001",
            "contentDesc":{
                "i18nValue":{
                    "en_US":"yourAlertContent",
                    "zh_CN":"yourAlertContentInChinese"
                }
            },
            "eventType":0,
            "tag":{
                "yourTag1":"yourValue1",
                "yourTag2":"yourValue2"
            }
        }
    ]
}
Java SDK 调用示例¶
public void testSearchHistoryAlerts(){
    String accessKey = "yourAppAccessKey";
    String secretKey = "yourAppSecretKey";
    SearchHistoryAlertRequest request = new SearchHistoryAlertRequest();
    request.setOrgId("yourOrgId");
    request.setStartOccurTime("2019-05-20T00:00:00Z");
    request.setEndOccurTime("2019-06-15T00:00:00Z");
    Pagination pagination = new Pagination();
    pagination.setPageSize(2);
        pagination.setPageNo(1);
        request.setPagination(pagination);
        request.setExpression("eventId='yourEventId'");
        try {
            SearchHistoryAlertResponse response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey).debug())
                    .url("https://{apigw-address}")
                    .getResponse(request, SearchHistoryAlertResponse.class);
            Gson gson = new Gson();
            System.out.println(gson.toJson(response));
        }catch(Exception e){
            System.out.print(e);
        }
}