Batch Create Alerts¶
Batch create alert records, up to 1000 items at a time.
Request Format¶
POST https://{apigw-address}/alert-service/v2.1/alerts?action=batchCreate
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 |
---|---|---|---|
alertVoList |
Mandatory |
Array of AlertVo Struct |
The list of alerts. For more information, see AlertVo Struct. |
AlertVo Struct ¶
Name |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|
eventType |
Mandatory |
Integer |
Only 2, 3, and 4 is applicable for Create Alert API. |
orgId |
Optional |
String |
The organization ID which the asset belongs to. |
instanceId |
Mandatory |
String |
The instance of the alert. At this stage there is only asset, thus it is the asset ID. |
metricId |
Mandatory |
String |
The ID of the original metric data. |
occurTime |
Mandatory |
Long |
The UTC time when the alert occurs. For time formats, see ISO8601 Standard Time Formats Used by UTC>> |
localOccurTime |
Optional |
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 |
Optional |
String |
The recovery time in local format. For time formats, see Data and Time Formats Used by Localtime>> |
recoverReason |
Optional |
String |
The recovery reason. |
value |
Mandatory |
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 |
Optional |
Map |
The metric data tag. The Key and Value are of String type. For more information, see How to use tags.
|
severityId |
Optional |
String |
The alert severity ID. |
severityDesc |
Optional |
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 |
Optional |
String |
The alert type ID. |
typeDesc |
Optional |
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 |
Optional |
String |
The alert type ID of the parent alert. |
parentTypeDesc |
Optional |
StringI18n |
The description of ID of the parent alert. For more details on the structure and locales supported, see Internationalized name struct. |
content |
Optional |
StringI18n |
The alert content. For more details on the structure and locales supported, see Internationalized name struct. |
ruleId |
Optional |
String |
The rule ID. |
ruleDesc |
Optional |
StringI18n |
The rule description. For more details on the structure and locales supported, see Internationalized name struct. |
ruleTags |
Optional |
Map |
The rule tag. |
tags |
Optional |
Map |
The user-defined tags. (The Key and Value are of String type.) For more information, see How to use tags. |
inhibited |
Optional |
Boolean |
|
Response Parameters¶
Name |
Data Type |
Description |
---|---|---|
data |
Array of EnosBatchEachData Struct |
The list of success or failure messages. For more information, see EnosBatchEachData Struct. |
successSize |
Integer |
The number of sucessfully created active alerts. |
totalSize |
Integer |
The total number of active alerts to be created. |
EnosBatchEachData Struct ¶
Name |
Data Type |
Description |
---|---|---|
code |
Integer |
Failed or succeeded to create an alert. 0: succeeded, -1: failed. |
msg |
String |
The message indicating whether the format is correct or wrong. |
msg |
String |
If successful, it will return the |
Samples¶
Request Sample¶
url: POST https://{apigw-address}/alert-service/v2.1/alerts?action=batchCreate&orgId=yourOrgId
method: POST
requestBody:
{
"alertVoList":[
{
"eventType":3,
"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":{
"modelId":"modelId_11",
"modelIdPath":"path"
},
"severityId":"42j",
"severityDesc":{
"i18nValue":{
"en_US":"wow",
"zh_CN":""
}
},
"typeId":"11d",
"typeDesc":{
"i18nValue":{
"en_US":"wow",
"zh_CN":""
}
},
"parentTypeId":"d1",
"parentTypeDesc":{
"i18nValue":{
"en_US":"wow",
"zh_CN":""
}
},
"content":{
"i18nValue":{
"en_US":"wow",
"zh_CN":""
}
},
"ruleId":"5v7",
"ruleDesc":{
"i18nValue":{
"en_US":"wow",
"zh_CN":""
}
},
"ruleTags":{
"color":"red",
"category":"note"
},
"tags":{
"de":"haha"
},
"inhibited":false
},
{
"eventType":3,
"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":{
"modelId":"modelId_11",
"modelIdPath":"path"
},
"severityId":"42j",
"severityDesc":{
"i18nValue":{
"en_US":"wow",
"zh_CN":""
}
},
"typeId":"11d",
"typeDesc":{
"i18nValue":{
"en_US":"wow",
"zh_CN":""
}
},
"parentTypeId":"d1",
"parentTypeDesc":{
"i18nValue":{
"en_US":"wow",
"zh_CN":""
}
},
"content":{
"i18nValue":{
"en_US":"wow",
"zh_CN":""
}
},
"ruleId":"5v7",
"ruleDesc":{
"i18nValue":{
"en_US":"wow",
"zh_CN":""
}
},
"ruleTags":{
"color":"red",
"category":"note"
},
"tags":{
"de":"haha"
},
"inhibited":false
}
]
}
Return Sample¶
{
"code":0,
"msg":"OK",
"requestId":"829db237-c850-4c58-a692-64ebe2105309",
"data":[
{
"code":0,
"msg":"format right",
"data":"2020101011ee0917bcd4f740decfaba8f27613c5"
},
{
"code":0,
"msg":"format right",
"data":"2020101011ee0917bcd4f740decfaba8f27613c5"
}
],
"successSize":2,
"totalSize":2
}
Java SDK Sample¶
public void testBatchCreateAlerts(){
String accessKey = "yourAppAccessKey";
String secretKey = "yourAppSecretKey";
BatchCreateAlertsRequest request = new BatchCreateAlertsRequest();
request.setOrgId("yourOrgId");
List<AlertVo> alertVoList = new ArrayList<>();
alertVoList.add(buildAlert());
alertVoList.add(buildAlert());
request.setAlertVoList(alertVoList);
try {
BatchCreateAlertsResponse response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey).debug())
.url("https://{apigw-address}")
.getResponse(request, BatchCreateAlertsResponse.class);
Gson gson = new Gson();
System.out.println(gson.toJson(response));
}catch(Exception e){
System.out.print(e);
}
}