Read Aggregate of Events

Retrieves aggregate of events grouped by the event type for the specified time interval

You can use this method to retrieve aggregates of events for each event type. The method performs the following:

  • Retrieves latest events grouped by the correlation ID.

  • Retrieves the first occurrence of the event per event type for the calculated time bucket. The method also retrieves the count events retrieved.

For example, consider the following set of events:

Event ID Correlation ID Timestamp Event Type
E1 C1 10:00 am ET1
E2 C1 10:10 am ET1
E3 C1 11:10 am ET1
E4 C2 09:00 am ET1
E5 C2 09:30 am ET1
E6 C3 10:10 am ET2

The method /EventsAggregate/v1/Events?timerange=2016-02-10T09:00:00.514Z-2017-08-16T12:00:00.533Z&divisions=40 when executed, performs the following:

  • Retrieves latest events grouped by the correlation ID as depicted in the following table:

    Event ID Correlation ID Timestamp Event Type
    E3 C1 11:10 am ET1
    E5 C2 09:30 am ET1
    E6 C3 10:10 am ET2
  • From the list of latest events grouped by the correlation ID, the method retrieves the first occurrence of the event per event type. In this example, event E5 of event type ET1 with correlation ID C2 and event E6 of event type ET2 with correlation ID C3.

  • From the complete list of events, for a combination of event type (ET1) and correlation ID (C2), the method retrieves the first occurrence of the event (E4). The timestamp of this first occurred event (E4) created for the correlation ID (C2) is displayed as the created business timestamp in the response payload as indicated in the following table:

    Event ID Correlation ID Timestamp Event Type Creation Time
    E5 C2 09:30 am ET1 09:00 am
    E6 C3 10:10 am ET2 10:10 am

Request

URI: /EventsAggregate/v1/Events?timerange=<fromTime>-<toTime>&divisions=<division>

Operation Type: CRUD

HTTP Method: GET

Permissions: <tde>.r

Request Parameters

Parameter Required Data Type Description
fromTime Yes Timestamp Time from which the aggregates are calculated for events
toTime Yes Timestamp Time up to which the aggregates are calculated for events
divisions Yes Integer Number of divisions
thing ID No String Unique identifier of a thing
thing property No String Free text that describes the thing property
type No String Free text that describes the event

Query Request Parameters

Parameter Required Data Type Description
$filter No String Filter condition to be applied; valid fields are ThingId, ThingProperty, and Type.

Request Example

/EventsAggregate/v1/Events?timerange=2016-02-10T13:10:16.514Z-2017-08-16T13:10:16.533Z&divisions=40&$filter=ThingId eq '0089A1D3E6C444E8894FEE517320EC92'

Response

Response Status and Error Codes

Code Description
200 Data retrieved successfully

Payload

Format: XML

Media types supported are JSON and XML. The XML for this method has the following structure:

  <entry>
        <id>https://events-aggregate-sap-ci.cfapps.sap.hana.ondemand.com:443/EventsAggregate/v1/Events('core.automobiles%3AAlertEventType')</id>
        <title type="text">Events</title>
        <updated>2019-05-31T09:45:29.613Z</updated>
        <category term="com.sap.appiot.esa.Events" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"></category>
        <link href="Events('core.automobiles%3AAlertEventType')" rel="edit" title="Events"></link>
        <content type="application/xml">
            <m:properties>
                <d:EventType>core.automobiles:AlertEventType</d:EventType>
                <d:FirstOccuringEventId>42FFF4BFB4844A77B19B0F3ED13A459D</d:FirstOccuringEventId>
                <d:Timestamp>2018-07-08T05:30:00Z</d:Timestamp>
                <d:Count>2</d:Count>
                <d:ThingProperty>core.automobiles:TTCar/carWheel</d:ThingProperty>
                <d:ThingId>DFA5E70345E24205A065939A59A47FF2</d:ThingId>
                <d:SecondsDuration>7583400.0</d:SecondsDuration>
                <d:Type m:null="true"></d:Type>
                <d:CreatedBusinessTimestamp>2018-07-08T05:00:00Z</d:CreatedBusinessTimestamp>
            </m:properties>
        </content>
    </entry>
    <entry>
        <id>https://events-aggregate-sap-ci.cfapps.sap.hana.ondemand.com:443/EventsAggregate/v1/Events('core.automobiles%3AAlertEventType1')</id>
        <title type="text">Events</title>
        <updated>2019-05-31T09:45:29.613Z</updated>
        <category term="com.sap.appiot.esa.Events" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"></category>
        <link href="Events('core.automobiles%3AAlertEventType1')" rel="edit" title="Events"></link>
        <content type="application/xml">
            <m:properties>
                <d:EventType>core.automobiles:AlertEventType1</d:EventType>
                <d:FirstOccuringEventId>96003CD12C5242A9848967DCA3D15670</d:FirstOccuringEventId>
                <d:Timestamp>2018-07-08T06:40:00Z</d:Timestamp>
                <d:Count>2</d:Count>
                <d:ThingProperty>core.automobiles:TTCar/carWheel</d:ThingProperty>
                <d:ThingId>DFA5E70345E24205A065939A59A47FF2</d:ThingId>
                <d:SecondsDuration>7579200.0</d:SecondsDuration>
                <d:Type m:null="true"></d:Type>
                <d:CreatedBusinessTimestamp>2018-07-08T06:30:00Z</d:CreatedBusinessTimestamp>
            </m:properties>
        </content>
    </entry>