DataBuilder - Scoped, Global

Use the DataBuilder class to create a series of data points for a metric. Use the sn_clotho.Client.put() method to save the values.

The DataBuilder class can be used in scoped and global server scripts. When using the DataBuilder class, use the sn_clotho namespace identifier.

This class is part of the MetricBase application.

Scoped DataBuilder - add(GlideDateTime start, Array value)

Add a series of data points to the DataBuilder object. Each data point is a time stamp and a value.

Uses the start parameter and the retention policy collection period to calculate the time stamp for each value in the array. The first value has the start parameter as the time stamp. This method does not save the data in the MetricBase database. Use the sn_clotho.Client.put() method to save the values.

Table 1. Parameters
Name Type Description
start GlideDateTime The time stamp for the first data point. Subsequent time stamps are calculated using the retention policy collection period.
value Array An array of numbers.
Table 2. Returns
Type Description
DataBuilder The same DataBuilder object.
var points = [7,0.5,273];
var dataBuilder = new sn_clotho.DataBuilder(gr, 'cpu_percentage');
// this creates a GlideDateTime object set to the current date and time
var time = new GlideDateTime();
dataBuilder.add(time, points);

Scoped DataBuilder - add(GlideDateTime start, Number value)

Add a data point to the DataBuilder object. Each data point is a time stamp and a value. This method does not save the data point in the metric. Use the sn_clotho.Client.put() method to save the values.

Table 3. Parameters
Name Type Description
start GlideDateTime The time stamp for the data point.
value Number The value of the data point.
Table 4. Returns
Type Description
DataBuilder The DataBuilder object.
var dataBuilder = new sn_clotho.DataBuilder(gr, 'cpu_percentage');
// this creates a GlideDateTime object set to the current date and time
var time = new GlideDateTime();
dataBuilder.add(time, 0.6);

Scoped DataBuilder - DataBuilder(String table, String subject, String metric)

Creates an instance of the DataBuilder class.

Table 5. Parameters
Name Type Description
table String Name of the table containing the GlideRecord associated with this series.
subject String The sys_id of the GlideRecord associated with this series.
metric String The field name of the metric.
// Where cpu_percentage is the name of the metric
var dataBuilder = new sn_clotho.DataBuilder(gr, 'cpu_percentage');