Scroll Alerts


Search for active and history alerts. The first search returns a pageToken to be used for the next search, and all subsequent searches will return a different pageToken to be used for its next search.

Request Format

POST https://{apigw-address}/alert-service/v2.1/alerts?action=scroll

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
instanceId Optional String The alert entity, which is the asset at this stage, with its value as the assetId.
metricId Optional String The metric, such as the measurement point.
startOccurTime Mandatory String The start time for triggering alert. To be used with endOccurTime. startOccurTime and endOccurTime cannot be more than 3 months apart. Time parameters used in API>>
endOccurTime Mandatory String The end time for triggering alert. To be used with startOccurTime. startOccurTime and endOccurTime cannot be more than 3 months apart. Time parameters used in API>>
startRecoverTime Optional String The start time of the alert recovery. To be used with recoverEndTime. If left blank, the data within the last week will be searched. Time parameters used in API>>
endRecoverTime Optional String The end time of the alert recovery. To be used with recoverStartTime. If left blank, the data within the last week will be searched. Time parameters used in API>>
active Optional Boolean
  • true: Search for active alerts.
  • false: Search for history alerts.
  • null (default): Search both active and history alerts.
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.

  • instanceId, metricId, severityId, typeId, parentTypeId, contentId, ruleId, eventType amd alertId: support operators “=”, “in” and “!=”
  • metricTags.*, ruleTags.* and tags.*: support operators “=”, “in”, “!=”, “like” and “exists”
  • inhibited: supports operators “=” and “!=”
  • maskedBy: supports operator “=”

For more information about field description, see AlertVo Struct

How to use expression>>

scroll Mandatory Scroll Struct The parameters used for the search. Results can only be sorted based on occurTime in descending order. For more information, see Scroll Struct.

Response Parameters

Name Data Type Description
data EnosScrollData Struct The returned results. EnosScrollData Struct>>

EnosScrollData Struct

Name Data Type Description
pageToken String The token for the next page.
pageSize int The number of records in each page.
sortedBy Array of Sorters Struct The sorting method. For more information, see Sorters Struct>>.
items Array of AlertVo Structs The list of alert records. For details of an AlertVo struct, see AlertVo Struct.

Samples

First Request Sample

url: https://{apigw-address}/alert-service/v2.1/alerts?action=scroll&orgId=yourOrgId
method: POST
requestBody:
{
    "endOccurTime":"2020-11-15T00:00:00Z",
    "startOccurTime":"2020-10-10T00:00:00Z",
    "scroll":{
        "pageSize":1
    }
}

Return Sample

{
    "code":0,
    "msg":"OK",
    "requestId":"64a0ac08-eba9-4fc9-ab67-20092ec8a7c8",
    "data":{
        "items":[
            {
                "alertId":"202011146df8f354ebbebe233eee5a3bba2e3a00",
                "eventType":3,
                "orgId":"yourOrgId",
                "instanceId":"231",
                "metricId":"int1",
                "occurTime":1605372245417,
                "localOccurTime":"2020-11-02 00:00:00",
                "recoverTime":null,
                "localRecoverTime":null,
                "recoverReason":null,
                "value":"int1",
                "metricTags":{
                    "modelId":"moni01",
                    "modelIdPath":"/moni01"
                },
                "severityId":"setSeverityId",
                "severityDesc":{
                    "defaultValue":"defaultDeviceName12:44:05AM",
                    "i18nValue":{
                        "en_US":"EnglishName",
                        "zh_CN":"中文名"
                    }
                },
                "typeId":"setSubTypeId",
                "typeDesc":{
                    "defaultValue":null,
                    "i18nValue":{

                    }
                },
                "parentTypeId":"setTypeId",
                "parentTypeDesc":{
                    "defaultValue":null,
                    "i18nValue":{

                    }
                },
                "content":{
                    "defaultValue":null,
                    "i18nValue":{

                    }
                },
                "ruleId":null,
                "ruleDesc":null,
                "ruleTags":{
                    "color": "orange"
                },
                "tags":{
                    "223":"new",
                    "224":"new1"
                },
                "inhibited":null
            }
        ],
        "sortedBy":[
            {
                "field":"occurTime",
                "order":"DESC"
            },
            {
                "field":"alertId",
                "order":"DESC"
            }
        ],
        "pageToken":"pageTokenExample",
        "pageSize":1
    }
}

Second Request Sample

url: https://{apigw-address}/alert-service/v2.1/alerts?action=scroll&orgId=yourOrgId
method: POST
requestBody:
{
    "scroll":{
        "pageSize":0,
        "pageToken":"pageTokenExample"
    }
}

Return Sample

{
    "code":0,
    "msg":"OK",
    "requestId":"44addba6-22d6-4290-9ef9-d064d3adced6",
    "data":{
        "items":[
            {
                "alertId":"202011145d4b63f0241a9dfb16f705d67cadadc3",
                "eventType":3,
                "orgId":"o15475450989191",
                "instanceId":"testBatch",
                "metricId":"int1",
                "occurTime":1605372245417,
                "localOccurTime":"2021-01-02 00:00:00",
                "recoverTime":null,
                "localRecoverTime":null,
                "recoverReason":null,
                "value":"int1",
                "metricTags":{
                    "modelId":"CCmodel",
                    "modelIdPath":"/CCmodel"
                },
                "severityId":"setSeverityId1",
                "severityDesc":null,
                "typeId":"setSubTypeId",
                "typeDesc":null,
                "parentTypeId":"setTypeId1",
                "parentTypeDesc":null,
                "content":null,
                "ruleId":null,
                "ruleDesc":null,
                "ruleTags":{
                    "color": "orange"
                },
                "tags":{

                },
                "inhibited":null
            }
        ],
        "sortedBy":[
            {
                "field":"occurTime",
                "order":"DESC"
            },
            {
                "field":"alertId",
                "order":"DESC"
            }
        ],
        "pageToken":"pageToken2",
        "pageSize":0
    }
}

Java SDK Sample

public void testScrollAlerts(){
    ScrollAlertRequest request = new ScrollAlertRequest();
    request.setOrgId(orgId);
    request.setStartOccurTime("2020-10-10T00:00:00Z");
    request.setEndOccurTime("2020-11-15T00:00:00Z");
    Scroll scroll = new Scroll(1, null,null);
    request.setScroll(scroll);

    try {
        ScrollAlertResponse response = Poseidon.config(PConfig.init().appKey(appKey).appSecret(appSecret).debug())
                .url(url)
                .getResponse(request, ScrollAlertResponse.class);

        for (AlertVo datum : response.getData().getItems()) {
            System.out.println(datum.getAlertId() + " " + datum.getLocalOccurTime());
        }

        ScrollAlertRequest request1 = new ScrollAlertRequest();
        request1.setOrgId(orgId);
        request.setStartOccurTime("2020-10-10T00:00:00Z");
        request.setEndOccurTime("2020-11-15T00:00:00Z");

        scroll = new Scroll(0, response.getData().getPageToken(),null);
        request1.setScroll(scroll);
        try {
            ScrollAlertResponse response1 = Poseidon.config(PConfig.init().appKey(appKey).appSecret(appSecret).debug())
                    .url(url)
                    .getResponse(request1, ScrollAlertResponse.class);

            for (AlertVo datum : response1.getData().getItems()) {
                System.out.println(datum.getAlertId() + " " + datum.getLocalOccurTime());
            }
        }catch(Exception e){
            System.out.print(e);
        }
    }catch(Exception e){
        System.out.print(e);
    }
}