azure - Getting the time frame in which a series of message is received in stream analytics -


i streaming event messages contain posix/epoch time field. trying calculate in time frame received series of messages device.

let's assume following (simplified) input:

[    { "deviceid":"device01", "epochtime":1500975613660 },    { "deviceid":"device01", "epochtime":1500975640194 },    { "deviceid":"device01", "epochtime":1500975649627 },    { "deviceid":"device01", "epochtime":1500994473225 },    { "deviceid":"device01", "epochtime":1500994486725 } ] 

the result of calculation should message {deviceid, start, end} each device id. assume new time frame starts, if time intervall between 2 events longer 1 hour. in example result in 2 transmissions:

[ {"deviceid":"device01", "start":1500975613660, "end"=1500975649627}, {"deviceid":"device01", "start":500994473225, "end"=1500994486725} ] 

i can convert epoch time according example 2 in documentation https://msdn.microsoft.com/en-us/library/azure/mt573293.aspx. however, cannot use converted timestamp lag function in sub query. values previoustime null in ouput.

with step1 ( select    [deviceid] deviceid,    system.timestamp ts,    lag([ts]) on (limit duration(hour, 24)) previoustime     input timestamp dateadd(millisecond, epochtime, '1970-01-01t00:00:00z')  ) 

i not sure how can perform calculation , what's best way it. need figure out beginning , end of event series.

any appreciated.

i modified query below in order expected result:

with step1 (   select        [deviceid] deviceid,     system.timestamp ts,     lag(dateadd(millisecond, epochtime, '1970-01-01t00:00:00z') ) on (limit duration(hour, 24)) previoustime         input timestamp dateadd(millisecond, epochtime, '1970-01-01t00:00:00z')  ) select * step1 

the problem "ts" defined in current step, when using lag looking @ original message coming from statement, , doesn't contain "ts" variable.

let me know if have question.

thanks,

js - azure stream analytics team


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -