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
- 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
orbackwards
Type:String
- limit
- 100 maximum number of stats to retrieve up to 1,000Type:
Number
- unit
- minute
minute
,hour
,day
ormonth
. 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.
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
- 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:ss
Type:String
- intervalId
- The UTC time period that the stats coverage begins at. If
unit
was requested asminute
this will be in the formatYYYY-mm-dd:HH:MM
, ifhour
it will beYYYY-mm-dd:HH
, ifday
it will beYYYY-mm-dd:00
and ifmonth
it will beYYYY-mm-01:00
Type:String
- schema
- The URL of a JSON schema describing the structure of the
Stats
objectType:String
StatsIntervalGranularity
StatsIntervalGranularity
is an enum specifying the granularity of a Stats interval
.
const StatsIntervalGranularity = [
'minute',
'hour',
'day',
'month'
]
CopyCopied!