Jump to: navigation, search

Stat Server API

Overview

This API is used to interact with the Genesys Statistics Server (Stat Server). The API provides the request so an application can get statistics related to the Contact Center.

Sequences Diagrams

GMS PeekStatSequence.png


GMS PeekStatSequence2.png


GMS UpdateStatCache.png


API

The Stat Server API exposes two interfaces:

  • "genesys/1/internal_statistic" - for internal access with no authentication control
  •  "genesys/1/statistic" - for external use, which uses Basic Access Authentication (BA) to authenticate users
As a standard protocol, username and password for BA can be passed in the URL, for example:
http://username:password@127.0.0.1:8080/genesys/1/statistic


PeekStat Request

This request gets the current value of the peek statistic.

Operation

Method POST
URL "/genesys/1/statistic" or "genesys/1/internal_statistic"
Parameter   Type   Mandatory Description
Header Parameters
Cache-Control : max-age=XX A number of seconds no The max-age value used to check if GMS has to recalculate the statistic. If the peek statistic time window is greater than maxAge, GMS recalculates the statistic value. If the value is not present, it returns the latest value in cache.
Body: The body can be either a MultiPart form or x-www-form-urlencoded form consisting of different items representing the key/value pairs associated with the statistic (objectId, objectType, tenant, tenantPassword, metric, notificationMode).

NotificationMode can be NoNotification, Reset, or Immediate.

Response

HTTP code 200
HTTP Message OK
HTTP Header Age: containing the age (in seconds) of the statistic value.
Body A json object representing the current statistic value. 

If a problem occurs during subscription, the following status codes are returned:


HTTP code 403
HTTP Message Forbidden
Body
Error message stating that the statistic is not well defined, for example:
{"message":"Place 'SIP_Server_Place' (Tenant 'Environment') not found","exception":"com.genesyslab.gsg.services.statistic.StatServerException"}


HTTP code 500
HTTP Message Internal server error
Body
If Stat Server is not connected, it returns, for example,
{"message":"Statistic Service unavailable","exception":"com.genesyslab.gsg.services.statistic.StatServerException"}

Example

Request

POST http://127.0.0.1:8080/genesys/1/statistic HTTP/1.1
Host: 127.0.0.1:8080
Connection: keep-alive
Content-Length: 91
Authorization: Basic ZGVmYXVsdDpwYXNzd29yZA==
Origin: chrome-extension://fdmmgilgnpjigdojojpjoooidkmcomcm
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.97 Safari/537.22
Content-Type: application/x-www-form-urlencoded
Accept: */*
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8,fr;q=0.6,fr-FR;q=0.4
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

objectId=KSippola&objectType=Agent&tenant=Environment&tenantPassword=&metric=TotalLoginTime

The following request is another example with cache-control set to two seconds:

POST http://127.0.0.1:8080/genesys/1/statistic HTTP/1.1 Host: 127.0.0.1:8080 Connection: keep-alive Content-Length: 91 Cache-Control: max-age=2 Authorization: Basic ZGVmYXVsdDpwYXNzd29yZA== Origin: chrome-extension://fdmmgilgnpjigdojojpjoooidkmcomcm User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.97 Safari/537.22 Content-Type: application/x-www-form-urlencoded Accept: */* Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8,fr;q=0.6,fr-FR;q=0.4 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

objectId=KSippola&objectType=Agent&tenant=Environment&tenantPassword=&metric=TotalLoginTime

Response

The following response is a json object representing the value for the statistic:

HTTP/1.1 200 OK
Pragma: no-cache
Cache-Control: no-cache
Cache-Control: no-store
Age: 9
Content-Length: 14
Content-Type: application/json
Server: Jetty(8.1.8.v20121106)

{"value":1025}

Extended API

PeekStat Request: Querying Multiple Statistic Values in a Single Request

This request gets the current values of several peek statistic objects.

Operation

Method POST
URL /genesys/1/statistics
Parameter   Type   Mandatory Description

 Body: The body is x-www-form-urlencoded form consisting of different items representing the key/value pairs associated with the statistic (objectId, type, tenantName...)

  • keystat<1>: the statistic object as Metric;ObjectType;ObjectId;TenantName
  • keystat<2>: the statistic object as Metric;ObjectType;ObjectId;TenantName
  • ...<n>:

Response

HTTP code 200
HTTP message OK
Body
A JSON array of key/value pairs: key is the key stat (see request) and value is the statistic value.

If a problem occurs during subscription, it will return the following status codes:

HTTP code 404
HTTP message Not Found
desc Statistic is not defined on StatServer side.


HTTP code 500
HTTP message A JSon exception
desc The exception contains the StatServer message.

Example

The following example shows a peek statistic with multiple statistic objects:

Operation

Request URL:http://localhost:8080/genesys/1/statistics
Request Method:POST
Status Code:200 OK
Request Headersview source
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:108
Content-Type: application/x-www-form-urlencoded
Host:localhost:8080
Origin:http://localhost:8080

stat1=ExpectedWaitTime;Queue;9002@SIP_Switch;Environment&stat2=ExpectedWaitTime;Queue;9001@SIP_Switch;Environment

Result
The above result is the array of statistic values.

HTTP 200 OK

{"stat1":10000,"stat2":10000}

 


Configuration

Stat Server Connection

In order to use the Stat Server API, there must be a connection to Stat Server in the GMS Application. You can create the connection in Configuration Manager on the Connections tab. See Creating and Configuring the GMS Application Cluster Object.

You can add several Stat Servers in the Connection tab; this feature is used in case of different statistic definitions in the Stat Servers. GMS will open the statistic on the Stat Server to which the statistic belongs to. In the case of the same statistic definition in Stat Servers, GMS will take the first Stat Server that contains the statistic definition.

ADDP Setting

Open Stat Server in the GMS Connection tab and set the connection protocol to addp. Set the values for the Local Timeout and Remote Timeout, and then select the Trace mode. See Implementing ADDP for more information.

Note: The addp traces are only visible on the Stat Server side. The following example shows an addp trace in Stat Server logs:

-AP[10]-<-2168 @15:37:30.4540

-Ap[10]->-2168 @15:37:30.4560

High Availability

If Stat Servers (defined in GMS connections) are configured to use High Availability (HA) (Primary/Backup Stat Server), in the case of a lost connection with the primary Stat Server, the Stat Server API will switch to the backup Stat Server.
This page was last modified on November 24, 2017, at 02:41.

Feedback

Comment on this article:

blog comments powered by Disqus