Last value of TS returned by `registerReadInterpolator` always 0


Is it normal that last value of TS returned by registerReadInterpolator is always 0?? like follows

This is the metric definition and evaluation:

var sm = SimpleMetric.make({
        "id" : "ElectricityConsumed",
        "name": "ElectricityConsumed",
        "srcType": "Facility",
        "path": "servicePoints.( == 'electricity').meters.measurements.(measurementType == 'consumed_totalizer')",
        "expression" : "registerReadInterpolator(avg(avg(, 'GT', 0, null)",
        "unit" : {
            "id" : "kilowatt_hour"

res = Facility.evalMetricsWithMetadata({
  }, [sm]);


When looking at the register measurements I can see points which have been used by the interpolator

Is it because the registerReadInterpolator has always one less points (as it calculates differences between consecutive points) than points in the raw measurements? Shouldn’t the evaluation fetch an additional measurement (as I have data outside the evaluation interval)?


You might want to read this Write a metric that outputs net values from incremental / lifetime values


@bachr the registerReadInterpolator function operates on the current data in memory and hence the last point is null since it doesn’t have another data point to diff against.

In order to solve this we had added RegisterNormalizer to make sure all the values are pre computed and we don’t miss a point.

If you do not want to use the normalizer but just this interpolated, a way would be to wrap inside and eval with a custom end of +1 interval. However this doesn’t guarantee that the data will be available for that interval ( hence the normalizer is a more complete solution)