Compare start() to datetime array Hot/Cold


I am working with Facilities that have devices, and each device has a measurement series. I have a couple of metrics I am trying to make work: SimpleMetric A, SimpleMetric B, SimpleMetric Datetime, and a CompoundMetric . Metrics A and B are standalone and working fine. Metric Datetime reads a value from the measurement series and returns it if it exists. e.g. “exists(datetime) ? datetime : null”. The compound metric should compare that datetime to “start()” and select metric A or B based on the result. e.g. “(start() > Metric Datetime) ? Metric A : Metric B”. The compound metric works for a single device. When calling the metric from a facility, I get an error that it can’t make the comparison between “start()” and “Metric Datetime”. I took a look at the result of Metric Datetime when called from a Facility and it returns an array of datetimes–one for each device measurement series under the facility. What I would like, is for each measurement series, it will make the comparison between the datetime and the start, and choose the correct metric A or B. I have been trying to play with the map function, but haven’t gotten it to work. Is there a way to compare “start()” to an array of values in this way?


Can you share how you’re using map and why it’s result does not match your expectations?


If your metric works fine at the device level, you might want to call rollupMetrics() for multiple devices instead of calling evalMetrics() at the Facility level…


@bachr the usage of map that I see in existing metrics from my project is always in simple metrics. I was not able to replicate that functionality: “sum(map())” without error. I according to documentation and c3base, you can make a call in the form of: “”. I tried several variations of “” but was not able to make the expressions to evaluate the mapped value against “start()”.

@ishka We were making these changes for performance reasons and my understanding was that using a rollup would be costly. The two options I found were to use a rollup or to move the logic to simple metrics and aggregate there. I’m currently trying a variation of the latter and it’s functional, but not quite as complete as I originally wanted. For our use-case it will suffice. It seems like collections need to be aggregated before the compound metric level.