0

我一直在使用以下siddhi query来获取每分钟的事件数;ts 作为时间戳(字符串)和 ftp_requests 作为计数(int)。

from FTPInStream[command == 'USER']
select time:timestampInMilliseconds(time:dateAdd(str:replaceAll(ts,'T',' '), 5, 'hour',"yyyy-MM-dd HH:mm:ss"),'yyyy-MM-dd HH:mm') as milliseconds , uid, id_orig_h, id_orig_p, id_resp_h, id_resp_p
insert into intermediateStream;

from intermediateStream#window.externalTimeBatch( milliseconds ,1 min, milliseconds, 1 min)
select time:dateFormat(milliseconds, 'yyyy-MM-dd HH:mm' ) as ts , cast(count(milliseconds), 'int') as ftp_requests
group by milliseconds
insert into FTPOutStream;

如果我想在每个新值中添加 ftp_requests 的先前值以获取每个新请求的累积请求数,需要进行哪些更改?siddhi 中是否有任何功能可以从已发布的流中获取先前的事件值?

4

1 回答 1

0

您不应该使用group by millisecondscount()也不应该需要任何参数,也不需要将其转换为 int。尝试以下查询。

from FTPInStream[command == 'USER']
select time:timestampInMilliseconds(time:dateAdd(str:replaceAll(ts,'T',' '), 5, 'hour',"yyyy-MM-dd HH:mm:ss"),'yyyy-MM-dd HH:mm') as milliseconds , uid, id_orig_h, id_orig_p, id_resp_h, id_resp_p
insert into intermediateStream;

from intermediateStream#window.externalTimeBatch( milliseconds ,1 min, milliseconds, 1 min)
select time:dateFormat(milliseconds, 'yyyy-MM-dd HH:mm:ss' ) as ts , count() as ftp_requests
insert into FTPOutStream;
于 2016-08-24T02:12:11.897 回答