Analytics Builder: check if creationtime of event is at a certain time window

Backend: 1011.0.4
UI: 1011.0.4

eu-latest for testing
I want to create an alarm, if a delta of two measurements is greater than 20 and occurs between 8:00 PM and 6:30 AM.
How to do this? Which block can be used for the time check?
The delta and the check for measuremnt > 20 is clear.



There are no inbuilt blocks to directly compare and check the times but you have few options to achieve what you want using existing block depending on the exact requirements.

Option 1: Use Cron Timer block

You can use Gate block along with couple of Cron Timer blocks to enable/disable the gate block. You pass the measurement values through the Gate block, so rest of the model will execute only when Gate block is open. This will allow you to compare measurement values only when Gate block is open and generate alarms if required. See the following example model. (1.2 KB)

One issue with this approach is that model need to be activated before the 8 PM otherwise gate block will remain closed until next 8 PM next day.

Option 2: Use Text Substitution block

As I mentioned earlier that Analytics Builder does not have any block to compare time or extract hour/minutes from a time but it has Text Substitution block which can generate format timestamp of measurements into string format “1970-08-12T02:00:37.000+05:30”. We can then use couple of Expression block to extract the hour and minutes from the time string. Then we can use another Expression block to check if the time is within the desired period. We can combine it again with the Gate block to enable/disable rest of the model which calculates delta and generate alarms. See the following example model. (1.5 KB)

Option 3: Use custom block

Another option would be write a custom block which can check directly check if the time is within the desired time period and use it with the Gate block like above. A custom block can be implemented using the block-sdk - GitHub - SoftwareAG/apama-analytics-builder-block-sdk: Apama Analytics Builder Block SDK



Hi Gyan
I implemented the first two and will check how it works out.
But sound reasonable for me.
The SDK will be a future task to check out.

Thanks a lot.