Analyze time series data

Use JavaScript or REST APIs to extract time series data from the MetricBase database, and to run transforms on the data.

For information on the MetricBase REST APIs see the REST API Explorer on an instance with the MetricBase application installed, or see the Clotho Time Series API.

For information on the MetricBase JavaScript APIs, see Client, ClothoTransform, Data, DataBuilder, and DataSelector APIs on the Developer Portal.

Analyze time series data with the JavaScript APIs

This example is to get the average CPU percentage over the specified time for each XYZ computer.

// Query the cmdb_ci_computer table for the records for 
var gr = new GlideRecord('cmdb_ci_computer');
gr.addEncodedQuery(‘manufacturer=xyz');
gr.query();

// Create a DataSelector object and specify the metric (cpu_percentage), 
// the transform (avg), and label (avg cpu)
var transform = new sn_clotho.DataSelector(gr).addMetric(‘cpu_percentage').avg()
                                              .label('avg-cpu-percentage');

// Run the transform between startTime and endTime. 
// startTime and endTime are GlideDateTime 
var data = new sn_clotho.Client().transform(transform, startTime, endTime);
var values = data[‘avg-cpu-percentage'].getValues();