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

Offline CallMeMaybe

  • Newbie
  • *
  • Posts: 9
  • Karma: 1
Get same data as from CC Pulse
« on: August 05, 2022, 09: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: [Select]
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);


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: [Select]
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);
}


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, 10:00:27 PM by CallMeMaybe »

Offline hsujdik

  • Hero Member
  • *****
  • Posts: 539
  • Karma: 29
Re: Get same data as from CC Pulse
« Reply #1 on: August 05, 2022, 11: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 06, 2022, 01:52:40 AM »
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


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: 7623
  • Karma: 56330
Re: Get same data as from CC Pulse
« Reply #3 on: August 06, 2022, 04:54:42 AM »
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: 539
  • Karma: 29
Re: Get same data as from CC Pulse
« Reply #4 on: August 07, 2022, 07:32:21 AM »
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


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)


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.

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, 03:32:15 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


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)


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.

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).

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, 04:31:15 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


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)


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.

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).

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:


stat I wanted taken from cc pulse:



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.

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, 05:40:16 PM by CallMeMaybe »

Offline hsujdik

  • Hero Member
  • *****
  • Posts: 539
  • Karma: 29
Re: Get same data as from CC Pulse
« Reply #7 on: August 08, 2022, 09: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, 05:46:40 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").

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?


Offline hsujdik

  • Hero Member
  • *****
  • Posts: 539
  • Karma: 29
Re: Get same data as from CC Pulse
« Reply #9 on: August 09, 2022, 10: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, 04:22:38 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)?

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: 7623
  • Karma: 56330
Re: Get same data as from CC Pulse
« Reply #11 on: August 10, 2022, 10: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, 02:44:05 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

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, 08:41:48 PM »
seems to work as intended. Thank you everyone!