Create Alert¶
Create an alert record.
Request Format¶
POST https://{apigw-address}/alert-service/v2.1/alerts?action=create
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 |
---|---|---|---|
alertVo |
Mandatory |
AlertVo Struct |
The details of the alert. 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 |
String |
The generated alert ID. |
Samples¶
Request Sample¶
url: POST https://{apigw-address}/alert-service/v2.1/alerts?action=create&orgId=yourOrgId
method: POST
requestBody:
{
"alertVo":{
"eventType":1,
"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":"dac2a872-b9b7-460c-992d-0a0c14ea36e9",
"data":"2019101011ee0917bcd4f740decfaba8f27613c5"
}
Java SDK Sample¶
public void testCreateAlerts(){
String accessKey = "yourAppAccessKey";
String secretKey = "yourAppSecretKey";
CreateAlertRequest request = new CreateAlertRequest();
request.setOrgId("yourOrgId");
request.setAlertVo(buildAlert());
try {
CreateAlertResponse response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey).debug())
.url("https://{apigw-address}")
.getResponse(request, CreateAlertResponse.class);
Gson gson = new Gson();
System.out.println(gson.toJson(response));
}catch(Exception e){
System.out.print(e);
}
}