如何计算一段时间内两个事件的数量?

时间:2019-07-10 01:56:45

标签: esper epl

这是两个事件:AppStartEvent和AppCrashEvent。
我需要计算一段时间内两个事件的数量,然后计算count(AppStartEvent)/ count(AppCrashEvent)。

我的EPL在这里

create context ctx4NestInCR 
context ctx4Time initiated @now and pattern [every timer:interval(1 minute)] terminated after 15 minutes, 
context ctx4AppName partition by appName from AppStartEvent, appName from AppCrashEvent
<------------------->
context ctx4NestInCR select count(s),count(c) from AppStartEvent as s, AppCrashEvent as c output last when terminated

它不起作用

Error starting statement: Joins require that at least one view is specified for each stream, no view was specified for s 

1 个答案:

答案 0 :(得分:0)

您的帖子没有加入?它仅具有上下文,并且不会产生消息。我建议改正该帖子。

您还可以通过合并两个流并将它们视为一个来加入流。

insert into AppEvent select 'crash' as condition from AppCrashEvent;
insert into AppEvent select 'start' as condition from AppStartEvent;
select count(condition='crash')/count(condition='start') from AppEvent;