MetricInfo - Scoped, Global

concept australia Updated Sep 10, 2026 2 min read MetricInfoBoth.md
Raw file servicenow.com

The MetricInfo API provides methods to check if a metric is in the MetricBase database, and if so, to report its retention policy. Retention policies are reported in minutes.

You can call this class in scoped and global server scripts. When using the MetricInfo class, use the sn_clotho namespace identifier.

This class is part of the MetricBase application.

Parent Topic:Server API reference

MetricInfo – MetricInfo(String table, String metric)

Creates an instance of the MetricInfo class.

Name Type Description
table String Metric table name listed in the Time Series Metrics [sys_metric] table.
metric String Metric field name listed in the Time Series Metrics [sys_metric] table. This field name must be mapped to the table name.

The following example shows how to construct a MetricInfo object with the Altitude (mb_demo_mt_altitude) metric associated with the Drones [mb_demo_drone] table.

JavaScript
var metricInfo =  new sn_clotho.MetricInfo('mb_demo_drone','mb_demo_mt_altitude');

MetricInfo – getRetentionSchedulesInMinutes()

Gets the retention policy schedules of the specified metric.

See also MetricBase retention policies.

Name Type Description
None

Type

Description

Object

JSON object containing key-value pairs that represent the retention policy schedules (in minutes) for the specified metric listed in the Retention Policies [sys_metric_retention_policy] table.For each retention policy schedule belonging to the metric, the object contains a corresponding key-value pair that maps the retention duration to the sampling period.

  • Key – Retention duration of the retention policy schedule in minutes.

Data type: String

  • Value – Sampling period of the retention policy schedule in minutes.

Data type: Number

Text
"<retentionDuration>": <samplingPeriod>
The following example shows how to loop over the retention policy schedules and compile a log message. The message contains the retention durations converted from minutes to days with their corresponding sampling periods.
JavaScript
// Function to convert minutes to daysfunction toDays(minutes) { return minutes / 60 / 24;};
var metricInfo = new sn_clotho.MetricInfo('mb_demo_drone','mb_demo_mt_altitude');var schedules = metricInfo.getRetentionSchedulesInMinutes();var log = '';
// Compiles a log message with retention schedulesfor (var duration in schedules) { log += "Retention duration is: " + toDays(duration) + " days, Sampling period is: " + schedules[duration] + " minutes\n";}
gs.info(log);

Output:

Python
Retention duration is: 8 days, Sampling period is: 1 minutesRetention duration is: 94 days, Sampling period is: 10 minutesRetention duration is: 397 days, Sampling period is: 60 minutes

MetricInfo – isValid()

Indicates whether the specified metric is mapped to the table defined in a MetricInfo object.

Name Type Description
None

Type

Description

Boolean

Flag that indicates whether the metric specified in a MetricInfo object is mapped to the specified table.

Valid values:

  • true: Specified metric is valid.
  • false: Specified metric or table either does not exist or the metric is not mapped to the table.
The following example shows how to check if the Altitude \(mb\_demo\_mt\_altitude\) metric is in the Drones \[mb\_demo\_drone\] table, and return its retention schedule if it is. The example output reflects the policy duration in minutes mapped to its interval sampling period.
JavaScript
var metricInfo =  new sn_clotho.MetricInfo('mb_demo_drone','mb_demo_mt_altitude');if (metricInfo.isValid()){  var retentionSchedules = metricInfo.getRetentionSchedulesInMinutes();  gs.info(JSON.stringify(retentionSchedules, null, 2));}else{  gs.info("metricInfo is invalid");}

Output:

JSON
{  "11520": 1,  "135360": 10,  "571680": 60}
Search documentation
Search document titles and file paths on the australia branch