How to get the total number of Incidents using Performance Analytics

Supreeth R1
Tera Contributor

Hello,

I've been trying to get the total number of incidents that were resolved within 15 minutes of their creation using Performance Analytics.

To do this I've written the below Script as there were no OOB filter conditions to apply in the Indicator level. Can someone guide me with the syntax and how to achieve this requirement? Thanks in advance!

find_real_file.png

var created = current.sys_created_on;
var resolved = current.resolved_at;
var diff = gs.dateDiff(created, resolved, true);
var div = diff/60;
var min = parseInt(div);
if (min < 15){
gs.info('CCCCCCCCC: '+min);
}

1 ACCEPTED SOLUTION

Nikita30
Mega Sage

Hi @Supreeth

 

Can you try the below code?

 

var created = current.sys_created_on;

var resolved = current.resolved_at;
var diff = gs.dateDiff(created, resolved, true);
var div = diff/60;
var min = parseInt(div);
if (min < 15){
return min;

 

}

Please mark the response as Helpful/Correct, if applicable. Thanks!

View solution in original post

2 REPLIES 2

Nikita30
Mega Sage

Hi @Supreeth

 

Can you try the below code?

 

var created = current.sys_created_on;

var resolved = current.resolved_at;
var diff = gs.dateDiff(created, resolved, true);
var div = diff/60;
var min = parseInt(div);
if (min < 15){
return min;

 

}

Please mark the response as Helpful/Correct, if applicable. Thanks!

Thanks for the quick response, Nikita. I tweaked the existing OOB Script for it apply in minutes as shown below. 

 

var diff = function(x, y) {
return y.dateNumericValue() - x.dateNumericValue();
};
var mins = function(x, y) {
return diff(x, y) / 60;
};
mins(current.sys_created_on, current.resolved_at);