Realtime SDK: Statistics

Methods

stats

Deferrable stats(Hash options) → yields 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

ParameterDescriptionType
optionsAn optional object containing the query parametersHash
&blockyields a PaginatedResult<Stats> objectBlock

options parameters

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

PropertyDescriptionType
:startEarliest Time or time in milliseconds since the epoch for any stats retrieved.
Default: beginning of time
Int or Time
:endLatest 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
:limitMaximum 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.

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

PropertyDescriptionType
unitThe length of the interval that this statistic covers, such as minute, hour, day or monthString
interval_idThe 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_timeA Time object representing the parsed interval_id (the UTC time at which the time period covered by this Stats object starts)Time
entriesThe 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 schemaHash
in_progressIf present, the last sub-interval, within the interval, for which statistics are included. Only present for an interval that is still in progressString
app_idThe ID of the Ably application the statistics relate toString
schemaThe URL of the JSON schema that describes the structure of entriesString