Aggregate Active Alerts


Calculate the number of active alerts.

Request Format

POST https://{apigw-address}/event-service/v2.1/active-alerts?action=aggregate

Request Parameters (URI)

Name

Mandatory/Optional

Data Type

Description

orgId

Mandatory

String

The organization ID which the asset belongs to. How to get orgId>>

Request Parameters (Body)

Name

Mandatory/Optional

Data Type

Description

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.

  • deviceStatus: supports operators “=” and “in”.

  • modelId, assetId, measurepointId, severityId, typeId, subTypeId, contentId, eventType, eventId, and hitRuleId: support operators “=”, “in”, and “!=”.

  • assetPath: supports operator “like”.

groupByField

Mandatory

String

The fields to group the results by. The fields supported are: contentId, assetId, modelId, measurepointId, severityId, typeId, subTypeId

startOccurTime

Optional

String

The start time for triggering the alert. For more details, see Time parameters used in API>>

endOccurTime

Optional

String

The end time for triggering the alert. For more details, see Time parameters used in API>>

Response Parameters

Name

Data Type

Description

data

Map

The Key (String type) is the value of the grouping field, and the value (Int type) is the number of alerts that the object has generated within the specified time range.

Samples

Request Sample

url: https://{apigw-address}/event-service/v2.1/active-alerts?action=aggregate&orgId=yourOrgId
method: POST
requestBody:
{
    "groupByField": "assetId",
  "action": "aggregate"
}

Return Sample

{
    "code": 0,
    "msg": "OK",
    "requestId": "12995105-514a-4706-9749-5930fd7145f9",
    "data": {
        "uEZPYKL0": 5,
        "J123maMn": 2,
        "Gx5mj2OE": 1,
        "qu5TmJRj": 1,
        "TMET5UCK": 1,
        "IkaNsY3h": 1,
        "L03wWUoU": 1,
        "OAESlCPt": 1
    }
}

Java SDK Sample

public void testAggregateActiveAlert(){
       String accessKey = "yourAccessKey";
       String secretKey = "yourSecretKey";
       AggregateActiveAlertRequest request = new AggregateActiveAlertRequest();
       request.setOrgId("yourOrgId");
       request.setGroupByField("assetId");
       request.headerParams().put("apim-accesskey","yourAccessKey");
           try {
               AggregateActiveAlertResponse response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey).debug())
                       .url("https://{apigw-address}")
                       .getResponse(request, AggregateActiveAlertResponse.class);
               Gson gson = new Gson();
               System.out.println(gson.toJson(response));
           }catch(Exception e){
               System.out.print(e);
           }
       }