0

I am using SiddhiQL for complex event processing. My use case is to check whether two events of a particular type with certain filters occur within 15 mins. Like for example -

If event1[filter 1] and event2[filter 2] within 15 mins
Insert into output stream 

In my case any of the two events can occur first and i need to check whether after receiving the first event, do i receive the second event within 15 mins.

Is this possible in SiddhiQL?

EDIT #1 - I have defined my streams and events below (The below code does not work)

define stream RegulatorStream(deviceID long, roomNo int, tempSet double);

@sink(type = 'log', prefix = "LOGGER")
define stream outputStream (roomNo int,rooomNo int);

from e1 = RegulatorStream[roomNo==23] and e2 = RegulatorStream[e1.deviceID == deviceID AND roomNo ==24] within 5 minutes 
select e2.roomNo,123 as rooomNo
insert into outputStream;

In above case, I need to alert when I receive events in my RegulatorStream having roomNo = 23 AND roomNo = 24 within 5 mins in any order with same deviceID.

How can this be achieved in SiddhiQL?

Community
  • 1
  • 1

1 Answers1

0

Yes this can achieved with Siddhi Patterns. Please refer the documentation on Siddhi Patterns in https://siddhi.io/en/v5.1/docs/query-guide/#pattern and examples in https://siddhi.io/en/v5.1/docs/examples/logical-pattern/.

You can use OR operation within the pattern to bypass the event occurrence order.

Chiran Fernando
  • 427
  • 3
  • 6
  • I am not getting you. Can you please show me an example – Vishal Gaikwad Jan 29 '20 at 06:18
  • Let me create a sample for your usecase. Can elaborate more on what will your two events be? What is the structure of the event and what are the two events you should receive to be triggered? – Chiran Fernando Jan 29 '20 at 07:15
  • Refer the sample for your usecase. This will emit an event foreach 23,24 and 24,23 combinations if events occur within 5minutes. – Chiran Fernando Jan 30 '20 at 11:07
  • from every( e1=RegulatorStream ) -> e2=RegulatorStream[ e1.deviceID == deviceID and (e1.roomNo==23 and e2.roomNo==24) or (e1.roomNo==24 and e2.roomNo==23) ] within 5 minutes select e2.roomNo,123 as rooomNo insert into outputStream; – Chiran Fernando Jan 30 '20 at 11:07
  • thanks for your response. But this does not work as intended because if i send 3 events with roomNo = 23 and one event with roomNo = 24, I receive 3 events in output stream, but what i intend to do is output only the last event with roomNo = 23 and roomNo =24 – Vishal Gaikwad Jan 30 '20 at 13:18