Esper:注意,当事件数量(具有特定参数)超过阈值时

发布于 2024-11-27 02:56:51 字数 745 浏览 0 评论 0原文

寻找解决方案已经很长时间了:

我有一个联系表。每次有人通过它发送邮件时,都会向 Esper 发出 ContactEvent(receiver, senderIpAddress)。现在,当特定 IP 地址在 10 分钟内发出超过 50 个联系事件时,我希望 Esper 通知我。

下面代码中的语法错误是由于代码简化造成的

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

,然后我像这样填充它:

insert into ContactWindow select ipAddress, mail from ContactEvent";

最终,有一个类似这样的事件侦听器:

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

这实际上有效。这并不完全是我想要的,因为每次发出我的语句侦听器时,IP 地址的消息计数都会发生变化。 (“IP X 在过去 10 分钟内发送了 43 条消息”,“IP X 在过去 10 分钟内发送了 44 条消息”,...) 我只想让一个事件告诉我“IP X 在过去 10 分钟内超过 50 条消息”,另一个事件告诉我,它现在已经低于该边界。

有办法让它发挥作用吗?

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 issued 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你爱我像她 2024-12-04 02:56:51

也许添加 having 子句。在你的例子中

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

Maybe add a having clause. In your example

select ip, count(ip) as cnt from ContactWindow  group by ip having count(ip)>50
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文