The script calls the metric aggregation scripted extension point and passes a configuration object that defines the aggregation. The following example aggregates a per-cell metric into an average value on each
Baseband Unit.
var impls = new GlideScriptedExtensionPoint()
.getExtensions('sn_tsom_em_conns.TSOMMetricAggregatorSEP');
if (!impls || !impls.length) {
gs.warn('TSOMMetricAggregator: No implementations registered for TSOMMetricAggregatorSEP');
} else {
impls[0].aggregate({
mode: 'hierarchy',
targetCIClass: 'cmdb_ci_baseband_unit',
sourceCIClass: 'cmdb_ci_mobile_cell',
sourceMetric: 'NR_5076b',
aggregate: 'avg',
calculatedMetricName: 'NR_5076b_avg_bbu',
unit: 'Mbps',
level: 4
});
}
For a flat, range-based aggregation, set the mode to flat, identify the source resources by range, optionally apply field filters, and provide the anchor CI that holds the result, as shown in the following
example.
var impls = new GlideScriptedExtensionPoint()
.getExtensions('TSOMMetricAggregatorSEP');
if (!impls || !impls.length) {
gs.warn('TSOMMetricAggregator: No implementations registered for TSOMMetricAggregatorSEP');
} else {
impls[0].aggregate({
mode: 'flat',
sourceCIClass: 'cmdb_ci_sim',
rangeStart: 'SIM010',
rangeEnd: 'SIM050',
filters: [
{ field: 'operational_status', operator: '=', value: '1' }
],
sourceMetric: 'sim_throughput',
aggregate: 'avg',
calculatedMetricName: 'sim_throughput_avg_global',
anchorCiSysId: '<sys_id>',
unit: 'Mbps'
});
}
To roll up only a subset of source CIs into a parent CI, use hierarchy mode and narrow the source resources by range and field filters, as shown in the following example. This example averages a metric across a range
of SIM cards with an active operational status and publishes the result to the parent mobile private network (MPN) service.
var impls = new GlideScriptedExtensionPoint()
.getExtensions('TSOMMetricAggregatorSEP');
if (impls && impls.length) {
impls[0].aggregate({
mode: 'hierarchy',
targetCIClass: 'cmdb_ci_network_service_instance',
sourceCIClass: 'cmdb_ci_sim_card',
rangeStart: 'PLMN-PLMN/SST-1/SD-000011',
rangeEnd: 'PLMN-PLMN/SST-1/SD-000015',
filters: [
{ field: 'operational_status', operator: '=', value: '1' }
],
sourceMetric: 'NR_5076b',
aggregate: 'avg',
calculatedMetricName: 'NR_5076b_avg_11_to_15_per_MPN_Service',
unit: 'Mbps',
level: 4
});
}
To reference the scripted extension point by its fully qualified scoped name and log a warning when no implementation is registered, use the following pattern.
var impls = new GlideScriptedExtensionPoint()
.getExtensions('sn_tsom_em_conns.TSOMMetricAggregatorSEP');
if (!impls || !impls.length) {
gs.warn('TSOMMetricAggregator: No implementations registered for TSOMMetricAggregatorSEP');
} else {
impls[0].aggregate({
mode: 'hierarchy',
targetCIClass: 'cmdb_ci_network_service_instance',
sourceCIClass: 'cmdb_ci_sim_card',
rangeStart: 'PLMN-PLMN/SST-1/SD-000011',
rangeEnd: 'PLMN-PLMN/SST-1/SD-000015',
filters: [
{ field: 'operational_status', operator: '=', value: '1' }
],
sourceMetric: 'NR_5076b',
aggregate: 'avg',
calculatedMetricName: 'NR_5076b_avg_11_to_15_per_MPN_Service',
unit: 'Mbps',
level: 4
});
}