I have pasted an example below but it might not do what you expect.
The elapsed time will almost always be 10m since that is the period of your 
window, except for  the first 10m where it will still be filling up.
Kapacitor measures time based on the data it sees. This means the window 
will not be emitted until a new point arrives.
If you are expecting the time difference of the window to not be 10m than 
that means that points are arriving less frequently than at 1m intervals. 
In which case emitting the window will be delayed until the next point 
arrives.


var vids = stream
        |from()
                .measurement('control')
                .groupBy('vid')


        |window()
                .period(10m)
                .every(1m)


var mins = vids
        |min('ping')
                .as('minping')


var first = vids
        |first('ping')
            .usePointTimes()
            .as('ping')


var last = vids
        |last('ping')
            .usePointTimes()
            .as('ping')

first
    |union(last)
    |elapsed('ping', 1s)
     

On Friday, September 9, 2016 at 7:24:55 AM UTC-6, e.p...@viriciti.com wrote:
>
> I'm trying to get the time difference between the first and the last item 
> within a window of 10 minutes using kapacitor. E.g.
>
> var vids = stream
>         |from()
>                 .measurement('control')
>                 .groupBy('vid')
>
>
>         |window()
>                 .period(10m)
>                 .every(1m)
>
>
> var mins = vids
>         |min('ping')
>                 .as('minping')
>
>
> var first = vids
>         |first('ping')
>
>
> var last = vids
>         |last('ping')
>
>
> It seems that first and last indeed contain the value of 'ping' of the 
> first resp. last time point in the window. 
>
> My question is: is it possible to get the time difference between these 
> two points. 
>
> (too) simply said:  last.time - first.time
>
> thanks
>

-- 
Remember to include the InfluxDB version number with all issue reports
--- 
You received this message because you are subscribed to the Google Groups 
"InfluxDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to influxdb+unsubscr...@googlegroups.com.
To post to this group, send email to influxdb@googlegroups.com.
Visit this group at https://groups.google.com/group/influxdb.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/influxdb/080a8a1f-2bcb-42ff-88be-d507c98c0cba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to