Re: [Dev] Getting accumulative values from stream

2016-08-23 Thread Grainier Perera
Hi Aneela,

At glace, there's some issues with your query. Is there a particular reason
for you to use `group by milliseconds`? otherwise you shouldn't be group by
such rapidly changing variable.  And also, the count aggregate  function
does not require any parameters and it does not have to be casted in to
int. Try the following query and see whether it works, if it doesn't can
you provide us with sample data and stream definitions?, then we can test
the query.

from FTPInStream[command == 'USER']
> select time:timestampInMilliseconds(time:dateAdd(str:replaceAll(ts,'T','
> '), 5, 'hour',"-MM-dd HH:mm:ss"),'-MM-dd HH:mm*:ss*') 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, '-MM-dd HH:mm' ) as ts , count() as
> ftp_requests
> insert into FTPOutStream;


Regards,
Grainier

On Tue, Aug 23, 2016 at 2:16 PM, Aneela Safdar  wrote:

> Hi,
>
> I have been using following siddhi query to get the events count per
> minute;  ts as timestamp (string) and ftp_requests as count (int)
>
> from FTPInStream[command == 'USER']
> select time:timestampInMilliseconds(time:dateAdd(str:replaceAll(ts,'T','
> '), 5, 'hour',"-MM-dd HH:mm:ss"),'-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, '-MM-dd HH:mm' ) as ts ,
> cast(count(milliseconds), 'int') as ftp_requests
> group by milliseconds
> insert into FTPOutStream;
>
> There is a need to populate ftp_requests parameter of FTPOutStream as
> accumulative i.e. (each new no of requests is addition of itself and
> previously added to stream). To achieve this I changed the query as below:
>
> from FTPInStream[command == 'USER']
> select time:timestampInMilliseconds(time:dateAdd(str:replaceAll(ts,'T','
> '), 5, 'hour',"-MM-dd HH:mm:ss"),'-MM-dd HH:mm') as milliseconds ,
> uid, id_orig_h, id_orig_p, id_resp_h, id_resp_p
> insert into intermediateStream;
>
> from intermediateStream
> select milliseconds, cast(count(milliseconds), 'int') as ftp_request
> group by milliseconds
> insert into intermediateStream111;
>
> from intermediateStream111#window.externalTimeBatch( milliseconds ,1 min,
> milliseconds, 1 min)
> select time:dateFormat(milliseconds, '-MM-dd HH:mm' ) as ts ,
> cast(sum(ftp_request), 'int') as ftp_requests
> insert into FTPOutStream;
>
> But I am getting nothing in ftp_requests parameter.
>
> Any suggestions?
>
> Regards,
> Aneela Safdar
>
> ___
> Dev mailing list
> Dev@wso2.org
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>
>


-- 
Grainier Perera
Software Engineer
Mobile : +94716122384
WSO2 Inc. | http://wso2.com
lean.enterprise.middleware
___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev


[Dev] Getting accumulative values from stream

2016-08-23 Thread Aneela Safdar
Hi,
I have been using following siddhi query to get the events count per minute;  
ts as timestamp (string) and ftp_requests as count (int)

from FTPInStream[command == 'USER']
select time:timestampInMilliseconds(time:dateAdd(str:replaceAll(ts,'T',' '), 5, 
'hour',"-MM-dd HH:mm:ss"),'-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, '-MM-dd HH:mm' ) as ts , 
cast(count(milliseconds), 'int') as ftp_requests
group by milliseconds
insert into FTPOutStream; There is a need to populate ftp_requests parameter of 
FTPOutStream as accumulative i.e. (each new no of requests is addition of 
itself and previously added to stream). To achieve this I changed the query as 
below:
from FTPInStream[command == 'USER']
select time:timestampInMilliseconds(time:dateAdd(str:replaceAll(ts,'T',' '), 5, 
'hour',"-MM-dd HH:mm:ss"),'-MM-dd HH:mm') as milliseconds , uid, 
id_orig_h, id_orig_p, id_resp_h, id_resp_p
insert into intermediateStream;

from intermediateStream
select milliseconds, cast(count(milliseconds), 'int') as ftp_request
group by milliseconds
insert into intermediateStream111;

from intermediateStream111#window.externalTimeBatch( milliseconds ,1 min, 
milliseconds, 1 min)
select time:dateFormat(milliseconds, '-MM-dd HH:mm' ) as ts , 
cast(sum(ftp_request), 'int') as ftp_requests
insert into FTPOutStream;

But I am getting nothing in ftp_requests parameter.
Any suggestions?
Regards, Aneela Safdar___
Dev mailing list
Dev@wso2.org
http://wso2.org/cgi-bin/mailman/listinfo/dev