MetricInfo - Scoped, Global
-
- UpdatedJan 30, 2025
- 2 minutes to read
- Yokohama
- API reference
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.
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. |
Example
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.
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.
|
Example
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.
Output:
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:
|
Example
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.
Output: