Statistics

stats(Object params?): Promise<PaginatedResult<Stats>>

This call queries the REST /stats API and retrieves your application’s usage statistics. A PaginatedResult is returned, containing an array of Stats for the first page of results. PaginatedResult objects are iterable providing a means to page through historical statistics. See an example set of raw stats returned via the REST API.

Parameters

params
an optional object set of parameters used to specify which statistics are retrieved. If not specified the default parameters will be used

params properties

The following options, as defined in the REST /stats API endpoint, are permitted:

start
beginning of time earliest time in milliseconds since the epoch for any stats retrievedType: Number
end
current time latest time in milliseconds since the epoch for any stats retrievedType: Number
direction
backwards forwards or backwardsType: String
limit
100 maximum number of stats to retrieve up to 1,000Type: Number
unit
minute minute, hour, day or month. Based on the unit selected, the given start or end times are rounded down to the start of the relevant interval depending on the unit granularity of the queryType: StatsIntervalGranularity

Returns

Returns a promise. On success, the promise is fulfilled with a PaginatedResult object containing an array of Stats objects. On failure, the promise is rejected with an ErrorInfo object.

A Stats object represents an application’s statistics for the specified interval and time period. Ably aggregates statistics globally for all accounts and applications, and makes these available both through our statistics API as well as your application dashboard.

Properties

appId
the ID of the Ably application the statistics relate to.Type: String
entries
The statistics for the requested time interval and time period. The schema property provides further informationType: Partial<Record<String, Number>>
inProgress
Optional. For entires that are still in progress, such as the current month, the last sub-interval included in the stats entry. In the format yyyy-mm-dd:hh:mm:ssType: String
intervalId
The UTC time period that the stats coverage begins at. If unit was requested as minute this will be in the format YYYY-mm-dd:HH:MM, if hour it will be YYYY-mm-dd:HH, if day it will be YYYY-mm-dd:00 and if month it will be YYYY-mm-01:00Type: String
schema
The URL of a JSON schema describing the structure of the Stats objectType: String

StatsIntervalGranularity is an enum specifying the granularity of a Stats interval.

JavaScript v2.9
const StatsIntervalGranularity = [ 'minute', 'hour', 'day', 'month' ]
Copied!
Select...