How to Measure State change metrics
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 11:05 PM
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??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 11:16 PM
Hi @Rutusha ,
You can create a metric definition which will capture the state duration.
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/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2024 12:45 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2024 01:44 AM
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/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-26-2024 11:22 PM
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();
}
}