C3 AI Documentation Home

Rollup Metrics

Rollup Metrics, available in the MetricEvaluatable Type, are a way of combining Timeseries from all sources into a single Timeseries to be used for a single metric.

Definition

Metrics can be rolled up by aggregating the results of all sources into a single Timeseries Type per metric by using rollupMetrics on a MetricEvaluatable Type.

The rollupMetrics method rollupMetrics(spec): map<string, Timeseries> accepts a RollupMetricSpec object which contains the same fields as the EvalMetricsSpec Type and a few additional fields.

  • rollupFunc (string) — Aggregation function to be used to roll up results of all individual sources into one Timeseries Type.
    • Options are OR, AND, SUM, AVG, MIN, MAX, MEAN, MEDIAN, VARIANCE, STDDEV, PERCENTILE.
  • percentileValue (double) — Percentile to be computed if the rollupFunc is PERCENTILE.

How to create a rollupmetric spec

The code snippet below creates a metric that calculates the total sum of the average power consumption of SmartBulbs manufactured by Philips between January 1, 2013, and March 1, 2013, on a daily basis.

JavaScript
var spec = RollupMetricSpec.make({
  filter: Filter.eq('manufacturer', 'Philips'),
  expressions: ["AveragePower"],
  start: "2013-01-01",
  end: "2013-03-01",
  interval: "DAY",
  rollupFunc: "SUM"
});
var result = SmartBulb.rollupMetrics(spec);
  • filter — A filter is applied to fetch the IDs that are used in evaluating for a single source type
  • expressions — Specify the expressions that you want to evaluate.
  • start — The field that represents the start date.
  • end — The field that represents the end date.
  • interval — One of the possible values of the standard normalized time intervals used most often for a Timeseries Types.
  • rollupFunc — Specify the aggregation function, in this case it is SUM, that rolls up results of all individual sources into a single Timeseries.

See also

Was this page helpful?