How to Stop Metric Timing on Resolved Incident?

BachAF
Tera Contributor

Hi All,

I want to capture metric data regarding the last group who resolved Incident. I created new metric definition: "Last Assignment Group to Resolve Inc" below:

find_real_file.png

So when an incident ticket is created, it is assigned to the first group, then when the incident gets assigned/escalated to another assignment group and get resolved, I want to see the "End" field, the "Duration" field get populated with data and the "Calculation complete" is set to true.

find_real_file.png

My goal is to have any Metrics on ticket should be marked to Calculation completed and timestamped appropriately when moving to Resolved.

Thanks in advance for your help.

1 ACCEPTED SOLUTION

BachAF
Tera Contributor

Thanks for your feedbacks, Adam Stout and Göran Lundqvist. Unfortunately, the customer has different requirement than SLA Breakdowns.

Anyway, I was able to find a work-around with the below steps:

1. Create New Metric: "Incident Resolved"

find_real_file.png

2. Create test Incident ticket:

find_real_file.png

 

3. Validate in Metric: "Assignment Group", 

find_real_file.png

Thank you.

Bachtiar

View solution in original post

9 REPLIES 9

Adam Stout
ServiceNow Employee
ServiceNow Employee

Why does the requestor care how you get it?  Why does it have to be a metric? 

SLA Breakdowns provide a lot more functionality (for instance resets, pauses, and business time).  

You can do this with a BR (but I'm not sure a metric) since the driving event isn't on the field that is changing.  When the incident is closed look up the existing metric and mark it complete.  I wouldn't do this, but it could be done.  SLA Breakdowns seem like a much better fit here. 

Hi,

That is hard. This is one of the times where the one who writes the requirements doesn't have the knowledge of how things work in ServiceNow and therefore writes solutions that probably isn't the best solution in both timewise to build, but also administrate it. I myself can't see why it needs to be in metrics. I would go back to whoever wrote the requirements and talk to them about the possibility to use SLA breakdowns instead. And as Adam writes below, the SLA Breakdowns also takes care of pitfalls like if the incident goes from resolved back to WIP and so on.

//Göran
Feel free to connect:
LinkedIn
Subscribe to my YouTube Channel
or look at my Book: The Witch Doctor's Guide To ServiceNow

Adam Stout
ServiceNow Employee
ServiceNow Employee

SLA Breakdowns seem like the way to go.  The danger with metrics here is what if it gets unresolved and you need to change it again?  if you already completed it, it could look at bit funky.

BachAF
Tera Contributor

Thanks for your feedbacks, Adam Stout and Göran Lundqvist. Unfortunately, the customer has different requirement than SLA Breakdowns.

Anyway, I was able to find a work-around with the below steps:

1. Create New Metric: "Incident Resolved"

find_real_file.png

2. Create test Incident ticket:

find_real_file.png

 

3. Validate in Metric: "Assignment Group", 

find_real_file.png

Thank you.

Bachtiar

Super helpful, thanks!

We're using it to track incident.priority but also wanted to stop tracking at incident.state == 'Resolved' vs 'Closed'. This works perfectly.

Here's the script typed out to make it easier for the next person:

//incident.state = Resolved is 6
if (current.state == 6) {
    answer = false;
    mi.endDuration();
    closeMetricDuration(mi.current);
}

function closeMetricDuration(current) {
    var gr = new GlideRecord('metric_instance');
    gr.addQuery('id', current.sys_id);
    gr.addQuery('calculation_complete', false);
    gr.addQuery('definition.type', 'field_value_duration');
    gr.addQuery('definition.name', 'Incident Priority Duration');
    gr.query();
    while (gr.next()) {
        var definition = new GlideRecord('metric_definition');
        definition.get(gr.definition);
        var mi = new MetricInstance(definition, current);
        mi.endDuration();
    }
}