Author Topic: Get same data as from CC Pulse  (Read 5919 times)

Offline CallMeMaybe

  • Newbie
  • *
  • Posts: 9
  • Karma: 1
Get same data as from CC Pulse
« on: August 05, 2022, 12:57:56 PM »
Hello!

I have tried to read all the development guide and googled a bunch but I must admit defeat!

We have a CC pulse stat server running and I want to get some of the same stats as visible in CC pulse but it does not seem to work as intended.
I am using the C# SDK


I want to get total number of CallsAnswered, the stat server automatically resets this stat at midnight, so I just want to peek/get the statistic from the same server
I tried to do this:

[code]
StatServerProtocol protocol = new StatServerProtocol(new Endpoint("host", port));
protocol.Open();

// Create Request
RequestGetStatistic req = RequestGetStatistic.Create();

//Request object
StatisticObject statobj = StatisticObject.Create();
statobj.ObjectId = "agent001";
statobj.ObjectType = StatisticObjectType.Agent;
statobj.TenantName = "Resources";
statobj.TenantPassword = "";
req.StatisticObject = statobj;

// Metrics
StatisticMetric statmet = StatisticMetric.Create("CallsAnswered");
req.StatisticMetric = statmet;

var response = protocol.Request(req);
Console.WriteLine(response);
[/code]


This is the statistic defined on the server:

[CallsAnswered]
Category=TotalNumber
Description=Total number of inbound and outbound calls answered by agents.
MainMask=CallAnsweredInbound, CallAnsweredOutbound
Objects=Agent, Place, GroupAgents, GroupPlaces
Subject=DNAction

Out of our ~50 agents it only works for like 5 agents. Is my code correct? Maybe issue is on stat server? Some other statistics work fine such as (AgentExtendedStatus)

I also tried RequestGetStatisticEx with defining my own masks etc like so:

[code]
RequestGetStatisticEx reqex = RequestGetStatisticEx.create();
var mainMask = new DNActionsMask();
mainMask.SetBit(DnActions.CallAnsweredInbound);
mainMask.SetBit(DnActions.CallAnsweredOutbound);
var relmask = new DNActionsMask();
relmask.ClearAll();
reqex.StatisticObject = StatisticObject.Create();
reqex.StatisticObject.ObjectId = "agent001";
reqex.StatisticObject.ObjectType = StatisticObjectType.Agent;
reqex.StatisticObject.TenantName = "Resources";
reqex.StatisticObject.TenantPassword = "";

reqex.StatisticMetricEx = StatisticMetrixEx.Create();
reqex.StatisticMetricEx.TimeProfile = "Default";
reqex.StatisticMetrixEx.Category = StatisticCategory.TotalNumber;
reqex.StatisticMetrixEx.Subject = StatisticSubject.DNAction;
reqex.StatisticMetricEx.MainMask = mainMask;
reqex.StatisticMetricEx.RelativeMask = relmask;
regex.StatisticMetricEx.IntervalType = StatisticInterval.SinceLogin;
protocol.Send(reqex);
while(true)
{
  var response = protocol.Receive();
  Console.WriteLine(response);
}
[/code]


In both examples I get back Eventinfo but the value is incorrect.
Additional info:
We got a main server and backup server in CC pulse idk if it has any influence.
« Last Edit: August 05, 2022, 01:00:27 PM by CallMeMaybe »

Offline hsujdik

  • Hero Member
  • *****
  • Posts: 541
  • Karma: 30
Re: Get same data as from CC Pulse
« Reply #1 on: August 05, 2022, 02:03:48 PM »
I wouldn't recommend using RequestGetStatistic for cumulative statistics (TotalNumber, TotalTime, AverageNumber, etc). It works well for Current numbers, but can have some weird behavior when using with cummulative numbers.

Instead, use RequestOpenStatistic (or RequestOpenStatisticEx) and handle the EventInfo in your EventHandler function.

Take a look on this code that could be similar to your needs:
http://www.sggu.com/smf/index.php/topic,12271.msg54747.html#msg54747

Offline CallMeMaybe

  • Newbie
  • *
  • Posts: 9
  • Karma: 1
Re: Get same data as from CC Pulse
« Reply #2 on: August 05, 2022, 04:52:40 PM »
[quote author=hsujdik link=topic=12333.msg54986#msg54986 date=1659708228]
I wouldn't recommend using RequestGetStatistic for cumulative statistics (TotalNumber, TotalTime, AverageNumber, etc). It works well for Current numbers, but can have some weird behavior when using with cummulative numbers.

Instead, use RequestOpenStatistic (or RequestOpenStatisticEx) and handle the EventInfo in your EventHandler function.

Take a look on this code that could be similar to your needs:
http://www.sggu.com/smf/index.php/topic,12271.msg54747.html#msg54747
[/quote]


Hey!

When you say cumulative, you mean TotalNumber being total inbound and outbound calls? Maybe there is another statistic I could pull? I am really only looking for the amount of inbound calls the agent has received on the day I run my application, I also don't want to periodically listen for events I just kind of want to read it and then close it.

Is there any example for Current number because I am not sure what you mean by that? (I thought Totalnumber of CallsAnswered was current number)

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7639
  • Karma: 56330
Re: Get same data as from CC Pulse
« Reply #3 on: August 05, 2022, 07:54:42 PM »
If you want to read and close then you are asking for Historical info, not real time.
Real time metrics are only populated by StatServer upon an application requests it to monitor such Metric. Unless you copy exactly what CCPulse is doing and requesting, you need to monitor your own Metric, which will begin to populate since the moment you request it.

Offline hsujdik

  • Hero Member
  • *****
  • Posts: 541
  • Karma: 30
Re: Get same data as from CC Pulse
« Reply #4 on: August 06, 2022, 10:32:21 PM »
[quote author=CallMeMaybe link=topic=12333.msg54987#msg54987 date=1659718360]
[quote author=hsujdik link=topic=12333.msg54986#msg54986 date=1659708228]
I wouldn't recommend using RequestGetStatistic for cumulative statistics (TotalNumber, TotalTime, AverageNumber, etc). It works well for Current numbers, but can have some weird behavior when using with cummulative numbers.

Instead, use RequestOpenStatistic (or RequestOpenStatisticEx) and handle the EventInfo in your EventHandler function.

Take a look on this code that could be similar to your needs:
http://www.sggu.com/smf/index.php/topic,12271.msg54747.html#msg54747
[/quote]


Hey!

When you say cumulative, you mean TotalNumber being total inbound and outbound calls? Maybe there is another statistic I could pull? I am really only looking for the amount of inbound calls the agent has received on the day I run my application, I also don't want to periodically listen for events I just kind of want to read it and then close it.

Is there any example for Current number because I am not sure what you mean by that? (I thought Totalnumber of CallsAnswered was current number)

[/quote]

TotalNumber is a cummulative (or rather, aggregated) statistic. All the statistics that has some amount calculated over time is a cummulative/aggregated statistic. For instance - Total Number of call answered = total number since when?? Then, the TimeProfile comes into play, to let StatServer know the span which the numbers are valid. The Default time profile, for example, is a Growing profile that resets at midnight. You can have different ones, like "SinceLogin", or a Window of time (e.g. last 24 hours, last 1 hour, total within the hour, etc).

That said, for all those aggregated statistics, statserver needs to know that they will be needed and they need to be persisted. And that's where the RequestOpenStatistic comes into play.

Per the Stat Server's users guide:
[quote]
Persistent Statistics

The term persistence means that a statistic, once requested by a client, continues to be calculated even after the client disconnects. Stat Server treats all requested statistics as persistent. When a statistic that is not already available on the server side is requested, it is automatically added to the Persistent Statistic Pool. Stat Server continues to calculate the statistic even after the requesting client closes it. When the client reopens the request for this statistic, the Persistent Statistic Pool resends it with accurate values to the client. By default, a statistic becomes obsolete and is removed from this pool three days after a client last requested it.
[/quote]

Now, If somebody had opened this statistic* before within the last 3 days, you should receive the correct return either with RequestOpenStatistic or RequestGetStatistic. However, my suggestion was merely because I have seen before RequestGetStatistic not as it should sometimes, so I always take the RequestOpenStatistic approach for any cummulative/aggregated statistic. Should you really need to get with RequestGetStatistic and are getting wrong values (given that this Very Same Statitistic* has been used in the previous 3 days), you should talk to Genesys Technical Support because might be some bug.

Now, I have marked "statistic" with an * for the following reason:
An statistic means a combination of things, and if one of those things is different, it is another statistic:
Object + Statistical Type + Time Profile + Time Range(s) (when applicable) + Filter, being Statistical Type a combination of Category + Main Mask + Relative Mask + Formula

So, for example, if you have used an statistic with Time Profile "A" in the past, it is still open, and then you need the very same data for the same object, but with Time Profile "B", it will start counting from the time you first requested (and will continue for as long as Stat Server keeps it open).

Offline CallMeMaybe

  • Newbie
  • *
  • Posts: 9
  • Karma: 1
Re: Get same data as from CC Pulse
« Reply #5 on: August 08, 2022, 06:32:15 AM »
[quote author=hsujdik link=topic=12333.msg54989#msg54989 date=1659825141]
[quote author=CallMeMaybe link=topic=12333.msg54987#msg54987 date=1659718360]
[quote author=hsujdik link=topic=12333.msg54986#msg54986 date=1659708228]
I wouldn't recommend using RequestGetStatistic for cumulative statistics (TotalNumber, TotalTime, AverageNumber, etc). It works well for Current numbers, but can have some weird behavior when using with cummulative numbers.

Instead, use RequestOpenStatistic (or RequestOpenStatisticEx) and handle the EventInfo in your EventHandler function.

Take a look on this code that could be similar to your needs:
http://www.sggu.com/smf/index.php/topic,12271.msg54747.html#msg54747
[/quote]


Hey!

When you say cumulative, you mean TotalNumber being total inbound and outbound calls? Maybe there is another statistic I could pull? I am really only looking for the amount of inbound calls the agent has received on the day I run my application, I also don't want to periodically listen for events I just kind of want to read it and then close it.

Is there any example for Current number because I am not sure what you mean by that? (I thought Totalnumber of CallsAnswered was current number)

[/quote]

TotalNumber is a cummulative (or rather, aggregated) statistic. All the statistics that has some amount calculated over time is a cummulative/aggregated statistic. For instance - Total Number of call answered = total number since when?? Then, the TimeProfile comes into play, to let StatServer know the span which the numbers are valid. The Default time profile, for example, is a Growing profile that resets at midnight. You can have different ones, like "SinceLogin", or a Window of time (e.g. last 24 hours, last 1 hour, total within the hour, etc).

That said, for all those aggregated statistics, statserver needs to know that they will be needed and they need to be persisted. And that's where the RequestOpenStatistic comes into play.

Per the Stat Server's users guide:
[quote]
Persistent Statistics

The term persistence means that a statistic, once requested by a client, continues to be calculated even after the client disconnects. Stat Server treats all requested statistics as persistent. When a statistic that is not already available on the server side is requested, it is automatically added to the Persistent Statistic Pool. Stat Server continues to calculate the statistic even after the requesting client closes it. When the client reopens the request for this statistic, the Persistent Statistic Pool resends it with accurate values to the client. By default, a statistic becomes obsolete and is removed from this pool three days after a client last requested it.
[/quote]

Now, If somebody had opened this statistic* before within the last 3 days, you should receive the correct return either with RequestOpenStatistic or RequestGetStatistic. However, my suggestion was merely because I have seen before RequestGetStatistic not as it should sometimes, so I always take the RequestOpenStatistic approach for any cummulative/aggregated statistic. Should you really need to get with RequestGetStatistic and are getting wrong values (given that this Very Same Statitistic* has been used in the previous 3 days), you should talk to Genesys Technical Support because might be some bug.

Now, I have marked "statistic" with an * for the following reason:
An statistic means a combination of things, and if one of those things is different, it is another statistic:
Object + Statistical Type + Time Profile + Time Range(s) (when applicable) + Filter, being Statistical Type a combination of Category + Main Mask + Relative Mask + Formula

So, for example, if you have used an statistic with Time Profile "A" in the past, it is still open, and then you need the very same data for the same object, but with Time Profile "B", it will start counting from the time you first requested (and will continue for as long as Stat Server keeps it open).
[/quote]

This is extremely helpful. So from what you are saying, GetStatistic should work if the statistic is already open on the statserver(opened by cc pulse?) but it has some weird/buggy behavior for cumulative stats? I will give OpenStatistic a go!

Offline CallMeMaybe

  • Newbie
  • *
  • Posts: 9
  • Karma: 1
Re: Get same data as from CC Pulse
« Reply #6 on: August 08, 2022, 07:31:15 AM »
[quote author=hsujdik link=topic=12333.msg54989#msg54989 date=1659825141]
[quote author=CallMeMaybe link=topic=12333.msg54987#msg54987 date=1659718360]
[quote author=hsujdik link=topic=12333.msg54986#msg54986 date=1659708228]
I wouldn't recommend using RequestGetStatistic for cumulative statistics (TotalNumber, TotalTime, AverageNumber, etc). It works well for Current numbers, but can have some weird behavior when using with cummulative numbers.

Instead, use RequestOpenStatistic (or RequestOpenStatisticEx) and handle the EventInfo in your EventHandler function.

Take a look on this code that could be similar to your needs:
http://www.sggu.com/smf/index.php/topic,12271.msg54747.html#msg54747
[/quote]


Hey!

When you say cumulative, you mean TotalNumber being total inbound and outbound calls? Maybe there is another statistic I could pull? I am really only looking for the amount of inbound calls the agent has received on the day I run my application, I also don't want to periodically listen for events I just kind of want to read it and then close it.

Is there any example for Current number because I am not sure what you mean by that? (I thought Totalnumber of CallsAnswered was current number)

[/quote]

TotalNumber is a cummulative (or rather, aggregated) statistic. All the statistics that has some amount calculated over time is a cummulative/aggregated statistic. For instance - Total Number of call answered = total number since when?? Then, the TimeProfile comes into play, to let StatServer know the span which the numbers are valid. The Default time profile, for example, is a Growing profile that resets at midnight. You can have different ones, like "SinceLogin", or a Window of time (e.g. last 24 hours, last 1 hour, total within the hour, etc).

That said, for all those aggregated statistics, statserver needs to know that they will be needed and they need to be persisted. And that's where the RequestOpenStatistic comes into play.

Per the Stat Server's users guide:
[quote]
Persistent Statistics

The term persistence means that a statistic, once requested by a client, continues to be calculated even after the client disconnects. Stat Server treats all requested statistics as persistent. When a statistic that is not already available on the server side is requested, it is automatically added to the Persistent Statistic Pool. Stat Server continues to calculate the statistic even after the requesting client closes it. When the client reopens the request for this statistic, the Persistent Statistic Pool resends it with accurate values to the client. By default, a statistic becomes obsolete and is removed from this pool three days after a client last requested it.
[/quote]

Now, If somebody had opened this statistic* before within the last 3 days, you should receive the correct return either with RequestOpenStatistic or RequestGetStatistic. However, my suggestion was merely because I have seen before RequestGetStatistic not as it should sometimes, so I always take the RequestOpenStatistic approach for any cummulative/aggregated statistic. Should you really need to get with RequestGetStatistic and are getting wrong values (given that this Very Same Statitistic* has been used in the previous 3 days), you should talk to Genesys Technical Support because might be some bug.

Now, I have marked "statistic" with an * for the following reason:
An statistic means a combination of things, and if one of those things is different, it is another statistic:
Object + Statistical Type + Time Profile + Time Range(s) (when applicable) + Filter, being Statistical Type a combination of Category + Main Mask + Relative Mask + Formula

So, for example, if you have used an statistic with Time Profile "A" in the past, it is still open, and then you need the very same data for the same object, but with Time Profile "B", it will start counting from the time you first requested (and will continue for as long as Stat Server keeps it open).
[/quote]

I tried this without luck, I tried to add a while loop that does .Receive and prints message, I see EventStatisticOpened, EventServerMode and then EventInfo, but the data in EventInfo is not correct unfortunately. Loop is not shown on picture but here is my configurations

Edit: after further testing, it seems to open the statistic but it starts from 0 as if I opened a completely new statistic (maybe I misconfigured it somehow?). I want to tap into the already opened one from cc pulse

my code:
[img width=380 height=480]https://i.imgur.com/zhLmyFm.png[/img]

stat I wanted taken from cc pulse:
[img]https://i.imgur.com/aT9mZcF.png[/img]


[quote author=cavagnaro link=topic=12333.msg54988#msg54988 date=1659729282]
If you want to read and close then you are asking for Historical info, not real time.
Real time metrics are only populated by StatServer upon an application requests it to monitor such Metric. Unless you copy exactly what CCPulse is doing and requesting, you need to monitor your own Metric, which will begin to populate since the moment you request it.
[/quote]

this is exactly what I want to do, I want to take the exact same statistic that our cc pulse has
« Last Edit: August 08, 2022, 08:40:16 AM by CallMeMaybe »

Offline hsujdik

  • Hero Member
  • *****
  • Posts: 541
  • Karma: 30
Re: Get same data as from CC Pulse
« Reply #7 on: August 08, 2022, 12:14:22 PM »
Don't open StatisticMetricEx in this case. It will be considered a different statistic by StatServer. Use the RequestOpenStatistic and pass the Statistical Type that you use in your CCPulse ("CallsAnswered").

Offline CallMeMaybe

  • Newbie
  • *
  • Posts: 9
  • Karma: 1
Re: Get same data as from CC Pulse
« Reply #8 on: August 09, 2022, 08:46:40 AM »
[quote author=hsujdik link=topic=12333.msg54996#msg54996 date=1659960862]
Don't open StatisticMetricEx in this case. It will be considered a different statistic by StatServer. Use the RequestOpenStatistic and pass the Statistical Type that you use in your CCPulse ("CallsAnswered").
[/quote]

I tried this, but it only seems to get me the agents for which I did openstatisticEx, so probably its getting the stats I opened myself.
Perhaps you can spot what I've done wrongly?

[img width=640 height=335]https://i.imgur.com/BDGZgtL.png[/img]

Offline hsujdik

  • Hero Member
  • *****
  • Posts: 541
  • Karma: 30
Re: Get same data as from CC Pulse
« Reply #9 on: August 09, 2022, 01:02:04 PM »
That looks ok. Maybe you have an Active-Standby pair of Stat Servers and they are set for accept-clients-in-backup-mode = true, and CCPulse is connecting to one of them whereas your application is connecting to the other (which doesn't have the statistics already open)?

Offline CallMeMaybe

  • Newbie
  • *
  • Posts: 9
  • Karma: 1
Re: Get same data as from CC Pulse
« Reply #10 on: August 10, 2022, 07:22:38 AM »
[quote author=hsujdik link=topic=12333.msg54999#msg54999 date=1660050124]
That looks ok. Maybe you have an Active-Standby pair of Stat Servers and they are set for accept-clients-in-backup-mode = true, and CCPulse is connecting to one of them whereas your application is connecting to the other (which doesn't have the statistics already open)?
[/quote]

When I check in CC pulse, we have both a primary server and a backup server, not sure if thats what you mean. I asked Genesys support within my company and they said both servers are on same port. What can I do?

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7639
  • Karma: 56330
Re: Get same data as from CC Pulse
« Reply #11 on: August 10, 2022, 01:00:49 PM »
Check in CCPulse the menu Environment Information. You will see there where you are connected at

Enviado de meu SM-N9600 usando o Tapatalk


Offline CallMeMaybe

  • Newbie
  • *
  • Posts: 9
  • Karma: 1
Re: Get same data as from CC Pulse
« Reply #12 on: August 11, 2022, 05:44:05 AM »
[quote author=cavagnaro link=topic=12333.msg55002#msg55002 date=1660136449]
Check in CCPulse the menu Environment Information. You will see there where you are connected at

Enviado de meu SM-N9600 usando o Tapatalk
[/quote]

I found that it connected to a different port than I initially configured, seems to now work, will have to test a bit

Offline CallMeMaybe

  • Newbie
  • *
  • Posts: 9
  • Karma: 1
Re: Get same data as from CC Pulse
« Reply #13 on: August 11, 2022, 11:41:48 AM »
seems to work as intended. Thank you everyone!