Search Alerts¶
Search for active and history alerts, where the pages of the returned results do not have to be in order.
Request Format¶
POST https://{apigw-address}/alert-service/v2.1/alerts?action=search
Request Parameters (URI)¶
| Name | Location (Path/Query) | Mandatory/Optional | Data Type | Description | 
|---|---|---|---|---|
| orgId | Query | Mandatory | String | The organization ID which the asset belongs to. How to get orgId>> | 
Request Parameters (Body)¶
| Name | Mandatory/Optional | Data Type | Description | 
|---|---|---|---|
| instanceId | Optional | String | The alert entity, which is the asset at this stage, with its value as the assetId. | 
| metricId | Optional | String | The metric, such as the measurement point. | 
| startOccurTime | Mandatory | String | The start time for triggering alert. To be used with  | 
| endOccurTime | Mandatory | String | The end time for triggering alert. To be used with  | 
| startRecoverTime | Optional | String | The start time of the alert recovery. To be used with  | 
| endRecoverTime | Optional | String | The end time of the alert recovery. To be used with  | 
| active | Optional | Boolean | 
 | 
| expression | Optional | String | The query expression, which supports sql-like query. The supported logical operators are “and” and “or”, and query fields are as per the below. 
 For more information about field description, see AlertVo Struct. | 
| pagination | Optional | Pagination Request Struct | Random pagination。 When not specified, 10 records are displayed per page by default and sorted in descending order by  | 
Response Parameters¶
| Name | Data Type | Description | 
|---|---|---|
| data | Array of AlertVo Structs | The list of alert records. For details of an AlertVo struct, see AlertVo Struct. | 
AlertVo Struct ¶
| Name | Data Type | Description | 
|---|---|---|
| alertId | String | The alert ID. | 
| eventType | Integer | 
 | 
| orgId | String | The organization ID which the asset belongs to. | 
| instanceId | String | The instance of the alert. At this stage there is only asset, thus it is the asset ID. | 
| metricId | String | The ID of the original metric data. | 
| occurTime | Long | The UTC time when the alert occurs. For time formats, see ISO8601 Standard Time Formats Used by UTC>> | 
| localOccurTime | String | The local time when the alert occurs. For time formats, see Data and Time Formats Used by Localtime>> | 
| recoverTime | Long | The recovery time in UTC format. For time formats, see ISO8601 Standard Time Formats Used by UTC>> | 
| localRecoverTime | String | The recovery time in local format. For time formats, see Data and Time Formats Used by Localtime>> | 
| recoverReason | String | The recovery reason. | 
| value | String | The metric value when the alert is generated. For alert functions such as multiple measurement point alerts or timed alerts, use the value of the metric that generates the alert. | 
| metricTags | Map | The metric data tag. The Key and Value are of String type. For more information, see How to use tags. 
 | 
| severityId | String | The alert severity ID. | 
| severityDesc | StringI18n | Specify the alert severity’s description in its respective locale’s language. For more details on the structure and locales supported, see Internationalized name struct. | 
| typeId | String | The alert type ID. | 
| typeDesc | StringI18n | Specify the alert type’s description in its respective locale’s language. For more details on the structure and locales supported, see Internationalized name struct. | 
| parentTypeId | String | The alert type ID of the parent alert. | 
| parentTypeDesc | StringI18n | The description of ID of the parent alert. For more details on the structure and locales supported, see Internationalized name struct. | 
| content | StringI18n | The alert content. For more details on the structure and locales supported, see Internationalized name struct. | 
| ruleId | String | The rule ID. | 
| ruleDesc | StringI18n | The rule description. For more details on the structure and locales supported, see Internationalized name struct. | 
| ruleTags | Map | The rule tag. | 
| tags | Map | The user-defined tags. (The Key and Value are of String type.) For more information, see How to use tags. | 
| inhibited | Boolean | 
 | 
Pagination Struct¶
| Name | Data Type | Description | 
|---|---|---|
| pageNo | Integer | The number of the returned page. | 
| pageSize | Integer | The number of the returned records on a single page. | 
| totalSize | Integer | The total number of the returned records. | 
| sortedBy | Array of Sorter struct | The pagination sorting method, supporting multiple sorting criteria. The earlier the sorting method appears, the higher its priority. | 
Sorter Struct¶
| Name | Data Type | Description | 
|---|---|---|
| field | String | The pagination field name. | 
| order | String | 
 | 
Samples¶
Request Sample¶
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
  }
}
Return Sample¶
{
    "pagination":{
        "pageNo":1,
        "pageSize":2,
        "totalSize":1,
        "sortedBy":[
            {
                "field":"occurTime",
                "order":"DESC"
            },
            {
                "field":"alertId",
                "order":"DESC"
            }
        ]
    },
    "code":0,
    "msg":"OK",
    requestId":"yourRequestID",
    "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
        }
    ]
}