Realtime SDK: Statistics
Methods
stats
Deferrable stats(Hash options) → yields PaginatedResult<Stats>
/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 |
|---|---|---|
| options | An optional object containing the query parameters | Hash |
| &block | yields a PaginatedResult<Stats> object | Block |
options parameters
The following options, as defined in the REST /stats API endpoint, are permitted:
| Property | Description | Type |
|---|---|---|
| :start | Earliest Time or time in milliseconds since the epoch for any stats retrieved. Default: beginning of time | Int or Time |
| :end | Latest Time or time in milliseconds since the epoch for any stats retrieved. Default: current time | Int or Time |
| :direction | :forwards or :backwards. Default: :backwards | Symbol |
| :limit | Maximum number of stats to retrieve up to 1,000. Default: 100 | Integer |
| :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 | Symbol |
Returns
A Deferrable object is returned from the stats method.
On success, the registered success callbacks for the Deferrable and any block provided to the method yields a PaginatedResult that encapsulates an array of Stats objects corresponding to the current page of results. PaginatedResult supports pagination using next and first methods.
Failure to retrieve the stats will trigger the errback callbacks of the Deferrable with an ErrorInfo object containing an error response as defined in the Ably REST API documentation.
Related types
Ably::Models::Stats
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.
Attributes
| Property | Description | Type |
|---|---|---|
| unit | The length of the interval that this statistic covers, such as minute, hour, day or month | String |
| interval_id | The UTC time at which the time period covered by this Stats object starts, at the resolution of unit: for example 2018-03-01:10:02 (minute), 2018-03-01:10 (hour), 2018-03-01 (day) or 2018-03 (month) | String |
| interval_time | A Time object representing the parsed interval_id (the UTC time at which the time period covered by this Stats object starts) | Time |
| entries | The statistics for the interval, as a flat Hash keyed by dot-separated metric name, such as messages.all.all.count. The set of metrics available is described by the JSON schema referenced by schema | Hash |
| in_progress | If present, the last sub-interval, within the interval, for which statistics are included. Only present for an interval that is still in progress | String |
| app_id | The ID of the Ably application the statistics relate to | String |
| schema | The URL of the JSON schema that describes the structure of entries | String |