Rollup Metric Use Case & Example


Can anyone provide a brief use case and example implementation of a Rollup Metric?


We use Rollup Metric, for performance reasons, to sum aggregate cached metrics of facilities that belong to an organization.

i.e. we have some metric “FacilityMetric” that gets cached. At the Organization level we evaluate the sum of the facilities that belong to it with something like:

  rollupFunc: "sum",
  expressions: ["FacilityMetric"],
  filter: Filter.intersects("parentOrgs", []),
  start: start,
  end: end,
  interval: interval,


Performance reason is not the right reason for using roll up metrics.

The main use case should be where for a given metric (say ElectricityConsumption) you want to roll up the values across all the sources ? E.g. What is the ElectricityConsumption across all of my facilities.

Now individual metrics can be cached if you are running into any performance issue



Would you use a rollup metric for some defined subset of the facilities? (ex: facilityState == “CA” )


yes that seems a legit use case. Essentially saying give me the rolled up value for my metric for all facilities in CA

p.s. be careful about the amount of information it can access - which is where the performance consideration will kick in. If you read the entire database, then these queries are bound to be slow


@rohit.sureka would it be more efficient and cleaner to leverage the type system and define a metric on a parent type of Facility for example Region so that the metric path already aggregates all the facilities within the region?


To clarify the example I provided above, the initial approach was to define a metric on a parent type as @romain.juban suggested, but because we were aggregating millions of measurement series in some cases, we ran into performance issues. That’s when we decided to pre-aggregate and cache at a lower level in the hierarchy and use the metric rollup at higher levels.