How to Measure State change metrics

Rutusha
Tera Contributor

Hi all,

We have requirement where we need to build metrics to measure state change.

 

Measure State change metrics - who caused, assignment group, when & how long the state is in particular duration .

Can someone please suggest on how to achieve this if you have built something similar??

5 REPLIES 5

AndersBGS
Tera Patron
Tera Patron

Hi @Rutusha ,

 

You can create a metric definition which will capture the state duration. 

AndersBGS_0-1709018115785.png

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

best regards

Anders

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/

HI,

This is totally accepted but how about the user who has worked in that specific state .

For that do we need to create another metric definition with field as assigned to.

Hi  @Rutusha ,

 

yes, the metric definition will only look at one field, so you need to create another metric definition to see who has been assigned. 

 

 

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.

 

best regards

Anders

If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.

Best regards
Anders

Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/

Community Alums
Not applicable

Hi @Rutusha ,

Please use the following script in the script section of the new metric form :

This script either provides a duration value or stops processing durations (sets the answer variable to false) when an incident is closed.

// script can set answer to false to terminate processing of the metric
    // mi - MetricInstance
    // answer
    if (!current.active) {
    answer = false;
    mi.endDuration();
    gs.log("Closing field durations");
    closeDurations(mi.current);
    }
    
    function closeDurations(current) {
    var now_GR = new GlideRecord('metric_instance');
    gr.addQuery('id', current.sys_id);
    gr.addQuery('calculation_complete', false);
    gr.addQuery('definition.type', 'field_value_duration');
    gr.query();
    while (gr.next()) {
    gs.log("closing: " + gr.definition.name + " for: " + current.number);
    var definition = new GlideRecord('metric_definition');
    definition.get(gr.definition);
    var mi = new MetricInstance(definition, current);
    mi.endDuration();
    }
    }