Search Alerts¶
查询当前和历史告警,返回结果可随便跳页。
请求格式¶
POST https://{apigw-address}/alert-service/v2.1/alerts?action=search
请求参数(URI)¶
| 名称 | 位置(Path/Query) | 必需/可选 | 数据类型 | 描述 | 
|---|---|---|---|---|
| orgId | Query | 必需 | String | 资产所属的组织 ID。如何获取 orgId 信息>> | 
请求参数(Body)¶
| 名称 | 必需/可选 | 数据类型 | 描述 | 
|---|---|---|---|
| instanceId | 可选 | String | 告警的实体,现阶段只有 asset,取值为 assetId。 | 
| metricId | 可选 | String | metric,比如测点。 | 
| startOccurTime | 必需 | String | 查询起始时间,与  | 
| endOccurTime | 必需 | String | 查询结束时间,与  | 
| startRecoverTime | 可选 | String | 查询起始时间,与  | 
| endRecoverTime | 可选 | String | 查询起始时间,与  | 
| active | 可选 | Boolean | 
 | 
| expression | 可选 | String | 查询表达式,支持类 SQL 的查询。目前支持的逻辑运算是 and 和 or,查询的字段和对应的运算符清单如下。 
 | 
| pagination | 可选 | Pagination 请求结构体 | 随机分页。只能按照  | 
响应参数¶
| 名称 | 数据类型 | 描述 | 
|---|---|---|
| data | AlertVo 结构体数组 | 告警记录的信息列表。有关 AlertVo 结构体的定义,参见 AlertVo 结构体。 | 
AlertVo 结构体 
| 名称 | 数据类型 | 描述 | 
|---|---|---|
| alertId | String | 告警 ID。 | 
| eventType | Integer | 
 其中,在 Create Alert 接口中,只允许填 2、3、4。 | 
| orgId | String | 资产所属的组织 ID。 | 
| instanceId | String | 告警的实体,现阶段只有 asset,取值为 assetId。 | 
| metricId | String | 原始度量数据的 ID。 | 
| occurTime | Long | 告警发生的时间,以 UTC 时间表示,格式见 UTC 采用的 ISO8601 标准时间格式>> | 
| localOccurTime | String | 告警发生的时间,以本地时间表示,格式见 localtime 采用的日期时间格式>> | 
| recoverTime | Long | 触发告警的异常状况恢复正常的时间,以 UTC 时间表示,格式见 UTC 采用的 ISO8601 标准时间格式>> | 
| localRecoverTime | String | 触发告警的异常状况恢复正常的时间,以本地时间表示,格式见 localtime 采用的日期时间格式>> | 
| recoverReason | String | 异常状况恢复的原因。 | 
| value | String | 告警产生时的 metric value,对于高级的告警功能比如多测点告警或者时序告警,使用产生告警对应的那个 metric 的 value。 | 
| metricTags | Map | 原始度量数据的标签。Key 和 Value 为 String。标签的作用与表示方法>> 
 | 
| severityId | String | 告警级别编号。 | 
| severityDesc | StringI18n | 告警级别描述。结构参见 国际化名称结构体。 | 
| typeId | String | 告警类型编号。 | 
| typeDesc | StringI18n | 告警类型描述。结构参见 国际化名称结构体。 | 
| parentTypeId | String | 告警父类型编号。 | 
| parentTypeDesc | StringI18n | 告警父类型描述。结构参见 国际化名称结构体。 | 
| content | StringI18n | 告警内容。结构参见 国际化名称结构体。 | 
| ruleId | String | 告警规则编号。 | 
| ruleDesc | StringI18n | 告警规则描述。结构参见 国际化名称结构体。 | 
| ruleTags | Map | 规则上的标签。 | 
| tags | Map | 标签,只支持全量更新。标签的作用与表示方法>> | 
| inhibited | Boolean | 
 | 
示例¶
请求示例¶
url: POST https://{apigw-address}/alert-service/v2.1/alerts?action=search&orgId=yourOrgId
method: POST
requestBody:
{
  "startOccurTime": "2019-05-20T00:00:00Z",
  "endOccurTime": "2019-06-15T00:00:00Z",
  "expression": "alertId = 'yourAlertId' and metricTags.modelId = 'modelId_11' and metricTags.assetTreePath in ('s3XMMLph', '2BRE9U8L', 'CkAQRo3y')",
  "pagination": {
    "pageNo": 1,
    "pageSize": 2
  }
}
返回示例¶
{
    "pagination":{
        "pageNo":1,
        "pageSize":2,
        "totalSize":1,
        "sortedBy":[
            {
                "field":"occurTime",
                "order":"DESC"
            },
            {
                "field":"alertId",
                "order":"DESC"
            }
        ]
    },
    "code":0,
    "msg":"OK",
    "requestId":"dac2a872-b9b7-460c-992d-0a0c14ea36e9",
    "data":[
        {
            "alertId": "yourAlertId",
            "eventType": 1,
            "orgId": "yourOrgId",
            "instanceId": "deviceId_37233",
            "metricId": "pointId_772",
            "occurTime": 1547824973674,
            "localOccurTime": "2018-01-01 01:01:01",
            "recoverTime": 1547824973674,
            "localRecoverTime": "2018-02-02 00:00:00",
            "recoverReason": "rpc",
            "value": "5",
            "metricTags":{
                "assetTreePath_s3XMMLph": "/JvQqIeUB/th1xnIG4/MlmbC7eG/",
                "assetTreePath": "2BRE9U8L:/nc34Xktx/DjEpY5Qz/MlmbC7eG/,CkAQRo3y:/grZH1o0Z/1ti4BAQU/MlmbC7eG/,s3XMMLph:/JvQqIeUB/th1xnIG4/MlmbC7eG/",
                "assetTreePath_2BRE9U8L": "/nc34Xktx/DjEpY5Qz/MlmbC7eG/",
                "modelId": "modelId_11",
                "modelIdPath" :"path"
            },
            "severityId": "42j",
            "severityDesc": {
                "i18nValue": {
                    "en_US": "warning",
                    "zh_CN": ""
                }
            },
            "typeId": "11d",
            "typeDesc": {
                "i18nValue": {
                    "en_US": "Limit",
                    "zh_CN": ""
                }
            },
            "parentTypeId": "d1",
            "parentTypeDesc": {
                "i18nValue": {
                    "en_US": "Threshold",
                    "zh_CN": ""
                }
            },
            "content": {
                "i18nValue": {
                    "en_US": "Content",
                    "zh_CN": ""
                }
            },
            "ruleId": "5v7",
            "ruleDesc": {
                "i18nValue": {
                    "en_US": "Rule description",
                    "zh_CN": ""
                }
            },
            "ruleTags":{
                "color": "red",
                "category" :"note"
            },
            "tags": {
                "de": "tag"
            },
            "inhibited": false
        }
    ]
}