Although in essence a metric is a numeric value of a quantity at a given time ServiceClarity provides the capability to calculate metadata about that value at that point in time. This is called the breakdown and more than one breakdown can be collected about a metric, depending on the capabilities of the underlying data source.
If we return to our first example the % critical issues we can imagine that it would be useful to know how that KPI breaks down by product line, service or component. Collecting this kind of metadata from a metric source such as JIRA is relatively simple. Lets rework the % critical issues formula to also return the breakdown by product - assuming our metric has been configure to collect this metadata.
This requires a slightly different approach to the KPI formula as this formula needs to work with the value for the metric and the metadata about that value.
- On line 1 as before we use the variable metrics to get the last known value for the metric: total number unresolved and as before we set a default value of 0
- On line 2 the same metrics variable is used to get the the metric: number of critical only this time we have used the getLatest() function to retrieved the last known object rather than the numeric value.
- On line 4 because the object also contains the metadata for the metric as well as the value we can extract the breakdown metadata for product
- On line 5 we also still need the numeric value for the critical number of issues, again we set a default value of 0
- On line 8 we calculate the percentage KPI value using the two numeric values.
- On lines 9-12 we return the numeric value for our metric and the breakdown metadata for product
- On line 15 we provide the correct alternative KPI value of zero critical issues