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.

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.

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);
  }
}