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.

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