The CreatorCon Call for Content is officially open! Get started here.

Average time to respond: Average function on the Automated Indicator returns weird metrics.

Waldo Lavaut1
Tera Contributor

If we want to measure 'Average time to Respond' from the user's perspective, we should follow a 24-hour schedule, right? (real-time).

There are a few tasks that to my understanding need to be done to achieve this:

1. First, create a new Metric to measure the time difference between incident opened - incident assigned (assigned to specifically).

Here's the script that I took from an SN Performance Analytics book (authored by SN):

if (current.assigned_to != "") {
    createMetric();
}

function createMetric() {
    var mi = new MetricInstance(definition, current);

    if (mi.metricExists()) return;

    var gr = mi.getNewRecord();

    gr.start = current.sys_created_on;
    gr.end = current.sys_updated_on;
	
// 	gr.duration will calculate the time difference between incident creation and incident assigned to
    gr.duration = gs.dateDiff(
        gr.start.getDisplayValue(),
        gr.end.getDisplayValue()
    );
    gr.calculation_complete = true;
    gr.insert();
}

 

2. Once we have this in production and we are collecting data, we can use the mi_duration property of that metric to report on it, right? 

So now we're left with the problem I have:

3. Create an automated Indicator to calculate the Average of all those metrics collected. This is what I did for the Automated Indicator: 

find_real_file.png

 

 

What I noticed after collecting the data is that if I select Hours or Days for the Unit, that's what it will show on the Analytics Hub. Which doesn't make sense to me. 

find_real_file.png

 

So my fear is that the Aggregate Average function on the Automated Indicator is NOT doing a real average calculation. 

 

find_real_file.png

 

The Metric I created initially on step 1 above is collecting UTC strings, so: 

 

- Do I need to convert those UTC strings to milliseconds to be able to calculate a real Average?

- Do I need to create two different automated indicators (count + sum) and then a formula indicator to achieve this?

- If so, how do I do a count and a sum when working with time? Can i sum or count milliseconds to get an average?

 

@Adam Stout , @Thomas Davis , @Slawek.Radziewicz , @Arnoud Kooi , @Ankur Bawiskar HELP PLEASE!

1 ACCEPTED SOLUTION

You need to convert to hours in order to Average Hours or days to Average Days. 

In dateDiff flag TRUE returns seconds and then we calculate hours and save it to record. 

 

start  = new GlideDateTime(gr.sys_created_on);
closed = new GlideDateTime(gr.closed_at);

dur_sec = gs.dateDiff(start, closed,true)
var dur_hours = Math.round(dur_sec / 3600);
  
}

View solution in original post

8 REPLIES 8

Waldo Lavaut1
Tera Contributor

@Adam Stout , @Thomas Davis , @Arnoud Kooi , @Ankur Bawiskar HELP!

VaranAwesomenow
Mega Sage

Did the data collection jobs execute successfully ? what do you see in scorecards ?

If I put Hours on the Unit the scores will show 1 Hour, 2 Hours, 3 Hours for different Assignment groups.

And if I put Days well...guess what. It will show 1 Day, 2 Days, 3 Days, whatever the Average function is trying to calculate, which makes me think there's something wrong here. 

Slawek_Radziewi
Kilo Sage

You need to verify what mi_duration field contain. It should contain hours not ms in order to use Hours Average later.