Statistics
stats
PaginatedResult<Stats> stats(Hash options)
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 |
|---|---|---|
| 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
On success, the returned PaginatedResult 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 raise an AblyException
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.
Please note that most attributes of the Stats type below contain references to further stats types. This documentation is not exhaustive for all stats types, and as such, links to the stats types below will take you to the Ruby library stats documentation which contains exhaustive stats documentation. Ruby and Python however uses under_score case instead of the default camelCase in most languages, so please bear that in mind.
Attributes
| Property | Description | Type |
|---|---|---|
| unit | the length of the interval that this statistic covers, such as :minute, :hour, :day, :month. | Stats::GRANULARITY |
| interval_granularity | Deprecated alias for unit; scheduled to be removed in version 2.x client library versions. | Stats::GRANULARITY |
| interval_id | the UTC time at which the time period covered by this Stats object starts. For example, an interval ID value of "2018-03-01:10" in a Stats object whose unit is day would indicate that the period covered is "2018-03-01:10 .. 2018-03-01:11". All Stats objects, except those whose unit is minute, have an interval ID with resolution of one hour and the time period covered will always begin and end at a UTC hour boundary. For this reason it is not possible to infer the unit by looking at the resolution of the interval_id. Stats objects covering an individual minute will have an interval ID indicating that time; for example "2018-03-01:10:02". | 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 |
| all | aggregate count of both inbound and outbound message stats | MessageTypes |
| api_requests | breakdown of API requests received via the Ably REST API | RequestCount |
| channels | breakdown of channel related stats such as min, mean and peak channels | ResourceCount |
| connections | breakdown of connection related stats such as min, mean and peak connections for TLS and non-TLS connections | ConnectionTypes |
| inbound | statistics such as count and data for all inbound messages received over REST and Realtime connections, organized into normal channel messages or presence messages | MessageTraffic |
| outbound | statistics such as count and data for all outbound messages retrieved via REST history requests, received over Realtime connections, or pushed with Webhooks, organized into normal channel messages or presence messages | MessageTraffic |
| persisted | messages persisted and later retrieved via the history API | MessageTypes |
| token_requests | breakdown of Ably Token requests received via the Ably REST API. | RequestCount |
| push | Detailed stats on push notifications, see our Push documentation for more details | PushStats |