开发者

Esper: Notice, when number of events (with specific parameters) exceeds a threshold

开发者 https://www.devze.com 2023-03-23 15:35 出处:网络
searching for a solution for this quite a long time: I have a contact form. Every time somebody sends a mail through it, a ContactEvent(receiver, senderIpAddress) is issued to Esper. Now, I would li

searching for a solution for this quite a long time:

I have a contact form. Every time somebody sends a mail through it, a ContactEvent(receiver, senderIpAddress) is issued to Esper. Now, I would like Esper to inform me, when a specific Ip Address issues more than 50 contact events in 10 minutes.

Syntax Errors in code below are due to code simplification

create window ContactWindow.win:time(10 min) as select ipAddress, mail from ContactEvent 

then I populate it like this:

insert into ContactWindow select ipAddress, mail from ContactEvent";

Eventually, there is an eventlistener on something like this:

select ip, count(ip) as cnt from ContactWindow  group by ip

Which actually works. It's not exactly what I would want tough, as my statement listener is issue开发者_JAVA技巧d each time, an ip addresse's message count changes. ("IP X has sent 43 messages the last 10 minutes", "IP X has sent 44 messages the last 10 minutes",...) I'd only like to get one event telling me "IP X is over 50 messages in the last 10 minutes" and another one telling me, that it has dropped below that border now.

Is there a way to get this to work?


Maybe add a having clause. In your example

select ip, count(ip) as cnt from ContactWindow  group by ip having count(ip)>50
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号