User-defined Views on Aggregations
Views are a means to apply specific functions/transformations to some of the built-in metrics in the API. These changes are non-destructive and will not filter/remove/modify any of the existing data access/presentation in the API. Views are ephemeral--they are not saved anywhere and only exist within the scope of a single API query. These can be the sole data element that you seek from your query or they can supplement existing conversation-focused aggregate metric queries.
Elements of Views
Views have a few basic attributes:
- a user-supplied name.
- a named function/transformation to be applied. These are built-in and not user-defined (but they are user parametrized).
- a "target" metric that the function will be applied to.
View Functions
Currently, there is only one built-in view function: a range bound. This allows you to remove some data from consideration before it gets aggregated. You can specify a lower-bound and/or an upper-bound to use as thresholds to eliminate "extreme" values, but at least one must be specified. So by way of example:
{
"target": "tAbandon",
"function": "rangeBound",
"range": {
"gte": 5000,
"lt": 10000
},
"name": "tKindOfShortAbandon"
}
This will create a new view named "tKindOfShortAbandon" which will aggregate all values of tAbandon that are greater-than-or-equal-to 5,000 milliseconds and are less-than 10,000 milliseconds.
Limitations
- Views are only available for aggregate metric endpoints.
- You are currently limited to 10 views in a single API call.
- View names cannot be the same as any of the Genesys Cloud built-in metric names.
- View target metrics can only be a built-in Genesys Cloud metric. That is, you cannot build views off of other views (no nesting/recursion).
- Range bound target metrics are limited to timer metric.
Example query
This example shows views used in a fully fleshed out conversation aggregates query. This example also highlights that you can specify more than one view in a single query:
{
"interval": "2016-11-06T00:00:00.000Z\/2017-01-06T00:00:00.000Z",
"granularity": "P1M",
"metrics": [
"tTalk",
"tHeld"
],
"groupBy": [
"direction"
],
"filter": {
"type": "and",
"predicates": [
{
"dimension": "queueId",
"value": "82688551-8d75-45ee-8cfb-822e0e0b9ef2"
}
]
},
"views": [
{
"target": "tTalk",
"function": "rangeBound",
"name": "tTalkShort",
"range": {
"lt": 1300000
}
},
{
"target": "tTalk",
"function": "rangeBound",
"range": {
"gte": 3600000
},
"name": "tTalkVeryLong"
}
]
}
Example response
This query returns tTalk and tHeld rolled up into one-month sized buckets from 11/06/2016 - 1/06/2017 broken out into groups by media type (implicitly) and direction, filtered to only a specific queue. In addition, it also returns tTalkShort (where tTalk is less than 1,300,000 milliseconds (1,300 seconds)) and tTalkVeryLong (where tTalk is greater-than-or-equal-to 3,600,000 milliseconds (1 hour)).
{
"results": [
{
"group": {
"mediaType": "email",
"direction": "outbound"
},
"data": [
{
"interval": "2016-11-06T00:00:00.000Z/2016-12-06T00:00:00.000Z",
"metrics": [
{
"metric": "tTalk",
"stats": {
"max": 2447049,
"count": 3,
"sum": 5302369
}
}
],
"views": [
{
"name": "tTalkShort",
"stats": {
"max": 1274205,
"count": 1,
"sum": 1274205
}
}
]
},
{
"interval": "2016-12-06T00:00:00.000Z/2017-01-06T00:00:00.000Z",
"metrics": [
{
"metric": "tTalk",
"stats": {
"max": 100590607,
"count": 32,
"sum": 115978914
}
},
{
"metric": "tHeld",
"stats": {
"max": 1175289,
"count": 12,
"sum": 1374876
}
}
],
"views": [
{
"name": "tTalkVeryLong",
"stats": {
"max": 100590607,
"count": 2,
"sum": 110690691
}
},
{
"name": "tTalkShort",
"stats": {
"max": 1175291,
"count": 29,
"sum": 3666054
}
}
]
}
]
},
{
"group": {
"mediaType": "voice",
"direction": "outbound"
},
"data": [
{
"interval": "2016-11-06T00:00:00.000Z/2016-12-06T00:00:00.000Z",
"metrics": [
{
"metric": "tTalk",
"stats": {
"max": 5770789,
"count": 2,
"sum": 6540426
}
}
],
"views": [
{
"name": "tTalkVeryLong",
"stats": {
"max": 5770789,
"count": 1,
"sum": 5770789
}
},
{
"name": "tTalkShort",
"stats": {
"max": 769637,
"count": 1,
"sum": 769637
}
}
]
},
{
"interval": "2016-12-06T00:00:00.000Z/2017-01-06T00:00:00.000Z",
"metrics": [
{
"metric": "tTalk",
"stats": {
"max": 2844,
"count": 2,
"sum": 4848
}
}
],
"views": [
{
"name": "tTalkShort",
"stats": {
"max": 2844,
"count": 2,
"sum": 4848
}
}
]
}
]
},
{
"group": {
"mediaType": "email",
"direction": "inbound"
},
"data": [
{
"interval": "2016-12-06T00:00:00.000Z/2017-01-06T00:00:00.000Z",
"metrics": [
{
"metric": "tTalk",
"stats": {
"max": 83220293,
"count": 17,
"sum": 85422692
}
},
{
"metric": "tHeld",
"stats": {
"max": 16515,
"count": 4,
"sum": 28251
}
}
],
"views": [
{
"name": "tTalkVeryLong",
"stats": {
"max": 83220293,
"count": 1,
"sum": 83220293
}
},
{
"name": "tTalkShort",
"stats": {
"max": 319866,
"count": 15,
"sum": 748161
}
}
]
}
]
}
]
}