我一直在使用siddhi query
来获取每分钟的事件数; ts为timestamp(字符串),ftp_requests为count(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中是否有任何函数可以从已发布的流中获取先前的事件值?
答案 0 :(得分:0)
您不应该使用group by milliseconds
,而count()
不应该要求任何参数,并且不需要将其转换为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;