Query find pattern with all events

Hi,

in a query i have thousands of events devided in four partitions.

My use-case is to send an event if the average of one value of all Events (last 10000) exeeds some level. So i have not really a pattern to detect. As i created the query with Apama Query Designer, i had to define a pattern.

Whats the best way to cover this use-case? Bold marked code is a pseudo pattern. I don’t need this.

inputs {
EventX() key block retain 10000 with unique uuid;

}

find every wait(20.0):w1 -> (EventX:f1 and EventX:f2)
[b]where f1.uLevel>100 and f2.uLevel>100[/b] 
select avg(f1.uLevel.toFloat()):e1  {

log("something...");
	%send("eventType":".com.nterra.kairos.EventY",
			"title":"sendEventY", "description":"",
			"channel":"\"\"",
			"fields": {
				"block":"\"f1.block\"",
				"avgSatisfaction":"\"e1\""
			});
}

Thanks!

Alex Enns

You can use a pattern of just a single event, and then add a having clause, which can use aggregates or select-ed values. For example:

find every EventX:f select avg(f.uLevel.toFloat()):e1 having e1 > 100.0 {

However, 10,000 events in a window is not ideal for queries - windows of up to 100 is the recommended size.

Thank you Chris!

But in case of retain=10,000: I’ve learned queries are for many, many small events while monitors are for less big events/objects.

What’s the best way to inspect thousands of events and put them through an aggregate function?

Regards

Alex