[kapacitor] Collect and compare two streams with sparse data

#1

Hello
I’m trying to use kapacitor to compare two measurements in real-time
Windowing system looks like a good solution for the task but for some reason it doesn’t cache points as I want it to do.

var e1 = stream
|from()
.measurement(‘m1’)
.where(lambda: “type” == ‘t1’)
|window()
.periodCount(2) // cache two points
.everyCount(1)

var e2 = stream
|from()
.measurement(‘m2’)
.where(lambda: “type” == ‘t2’)
|window()
.periodCount(2)
.everyCount(1)

var e1p = e1|last(‘a’)
|eval(lambda: “last”)
.as(‘a’)
|default()
.tag(‘key’, ‘e1’)

var e2p = e2|last(‘a’)
|eval(lambda: “last”)
.as(‘a’)
|default()
.tag(‘key’, ‘e2’)

e1p
|union(e2p)
|flatten() // merge two points
.on(‘key’)
|influxDBOut()

//

As result of this script I expect it to cache values from two streams separately because points are not synchronized in time. But in the result when there is no a point in one of the stream there is no any output - so it doesn’t cache values.
Can you please suggest me something how to solve this task?

Merging stream data using union not caching multiple points