GetStats

Returns statistics snapshots within a provided timestamp range. By default, snapshots are made every 10 seconds and they are stored for 1 hour.

These statistics include:

  • the number of connected users per protocol (not available for all protocols)
  • the number of ongoing requests
  • the number of completed requests since the last frame
  • the number of failed requests since the last frame

Arguments

Copied to clipboard!
func (s *Server) GetStats(
  startTime *time.Time,
  stopTime *time.Time,
  options types.QueryOptions
) (json.RawMessage, error)
Arguments Type Description
startTime
time.Time
begining of statistics frame set (timestamp or datetime format)
stopTime
time.Time
end of statistics frame set (timestamp or datetime format)
options
types.QueryOptions
An object containing query options.

Options

Additional query options

Option Type Description Default
Queuable
bool
If true, queues the request during downtime, until connected to Kuzzle again true

Return

Returns snapshots within the provided timestamp range as a json.RawMessage or a KuzzleError. See how to handle error.

Usage

Copied to clipboard!
start := time.Date(2001, time.September, 9, 1, 46, 40, 0, time.UTC)
stop := time.Now()
stats, err := kuzzle.Server.GetStats(&start, &stop, nil)
if err != nil {
  log.Fatal(err)
} else {
  fmt.Println("Kuzzle Stats as JSON string:", string(stats))
}