2

I'm trying to build an execution plan which aggregates different events into one and counts the occurrence (CurrentEventId). The plan looks like the following:

define stream inStream (correlation_EventName string, LastEventId int, CurrentEventId int);

partition with (CurrentEventId of inStream)
begin

    from inStream#window.timeBatch(10 sec)
    select correlation_EventName as meta_Label, CurrentEventId as meta_Id, LastEventId as correlation_From, CurrentEventId as correlation_To, count(CurrentEventId) as correlation_Value
    insert into outStream

end;

Actually, I have the following output:

Event: {"event":{"metaData":{"Label":"StartCalculationEvent","Id":2},"correlationData":{"From":2,"To":2,"Value":66}}}
Event: {"event":{"metaData":{"Label":"LoginEvent","Id":1},"correlationData":{"From":1,"To":1,"Value":693}}}

I need just a single event every 10 seconds and not multiple events. This event should have the following format:

[
    {
        "event":{"metaData":"..."}
    },
    {
        "event":{"metaData":"..."}
    }
]

Do you have an idea on how to realize that?

Community
  • 1
  • 1
Seb Krae
  • 311
  • 3
  • 10

1 Answers1

0

With siddhi partitions, separate events will be generated for each partition variable(in this case the CurrentEventId). Since you have two CurrentEventIds, you receive two events into outStream. If there were three CurrentEventIds you would have received 3 events separately.

As of now, there is no way to batch events in siddhi as you have requested. There is a related Jira which is similar to the functionality you are expecting.