I recall that I had a hard time with Alarms, to mitigate the issues I had to put in the EPL a condition status = active in order to take into consideration only the newest alarm since IN alarm Clears OUT alarm and OUT alarm clears IN alarm:
/////////////////////////////////////////////////////////////////////////////////////////////////////
on all Alarm(status= “ACTIVE”) as a1 {
if a1.type.contains(ALARM_IN_TYPE) {
on wait (2.0){
on Alarm(status= “ACTIVE”, source= a1.source) as a2 {
if a2.type.contains(ALARM_OUT_TYPE) {
//////////////////////////////////////////////////////////////////////////////////////////////////////
my question is: in events, there is no “status =active” to help, if an event happens it will be always taken into consideration by EPL? or an event is only taken into consideration when it happens? we will be measuring the time spent between IN Event and OUT Event
No there is no “status” in events as they do not go through an ACTIVE → ACKNOWLEDGED → CLEARED life cycle like alarms do. But also for alarms “status” might not be what you are looking for as ACTIVE does not mean the newest alarm necessarily.
Instead, both events and alarms have isCreate() and isUpdate() actions that tell you whether this is a new alarm or event or an update to an existing one. Have a look at the ApamaDoc, e.g. for Event#isCreate():
Note that there can be alarms for which isCreate() and isUpdate() both return false. These are alarms raised by an Analytics Builder model that are routed internally in Apama but have not been written to C8Y. Once they have been written to Apama, you will receive them again with either isCreate() and isUpdate() returning true. So it is safe to ignore the initial alarm where both actions return false.
thanks for the feedback, to make sure that I got it correctly, for events is it taken into consideration by EPL only when it happens? and the EPL code below is enough to catch the latest 2 IN/OUT? without any addition?
on all Event(type=IN_TYPE) as e1 {
on Event(type=OUT_TYPE, source= e1.source) as e2 {
or do we need to add isCreate() to the code in order to avoid catching old alarms historically?