Last value of TS returned by `registerReadInterpolator` always 0


#1

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.(resource.id == 'electricity').meters.measurements.(measurementType == 'consumed_totalizer')",
        "expression" : "registerReadInterpolator(avg(avg(normalized.data.quantity)), 'GT', 0, null)",
        "unit" : {
            "id" : "kilowatt_hour"
        }
    })

res = Facility.evalMetricsWithMetadata({
  "expressions":["ElectricityConsumed"],
  "interval":"TEN_MINUTE",
  "ids":["0072"],
  "start":"2019-01-15T08:01:00.000Z",
  "end":"2019-01-15T12:11:00.000Z"
  }, [sm]);

c3Viz(res)

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)?


#2

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


#3

@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)