Statistics
stats
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
| Parameter | Description | Type |
|---|---|---|
| params | An optional object containing the query parameters used to specify which statistics are retrieved. If not specified the default parameters will be used | Object |
params properties
The following options, as defined in the REST /stats API endpoint, are permitted:
| Property | Description | Type |
|---|---|---|
| start | Earliest time in milliseconds since the epoch for any stats retrieved. Default: beginning of time | Number |
| end | Latest time in milliseconds since the epoch for any stats retrieved. Default: current time | Number |
| direction | forwards or backwards. Default: backwards | String |
| limit | Maximum number of stats to retrieve up to 1,000. Default: 100 | Number |
| unit | 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 query. Default: minute | 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.
Related types
Stats 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
| Property | Description | Type |
|---|---|---|
| appId | the ID of the Ably application the statistics relate to. | String |
| entries | The statistics for the requested time interval and time period. The schema property provides further information | 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:ss | 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:00 | String |
| schema | The URL of a JSON schema describing the structure of the Stats object | String |
StatsIntervalGranularity
StatsIntervalGranularity is an enum specifying the granularity of a Stats interval.
1
2
3
4
5
6
const StatsIntervalGranularity = [
'minute',
'hour',
'day',
'month'
]