[Kapacitor] Stream task with two influxdbout nodes

I have a task with 4 UDFs. After two of them I would like to store the result in a measurement and after that I would like to continue the processing with the two remaining UDFs and store there result in a different measurement.
I tried the following things:

1.:

 stream
|from()
    .measurement('Beacon')
(at)smooth_rssi()
(at)calculate_distances()
|influxDBOut()
    .database('Beacons')
    .measurement('Distances')
(at)determine_positions()
smooth_positions()
|influxDBOut()
    .database('Beacons')
    .measurement('DevicePositions')

=> Syntax error

2.:

var firstresult = stream
|from()
.measurement(‘Beacon’)
(at)smooth_rssi()
(at)calculate_distances()
firstresult
|influxDBOut()
.database(‘Beacons’)
.measurement(‘Distances’)

firstresult
(at)determine_positions()
(at)smooth_positions()
|influxDBOut()
.database(‘Beacons’)
.measurement(‘DevicePositions’)

=> gets totally wrong input in third UDF

3: Two Tasks. Second is listening on first measurement.
=> After a few minutes the second Task gets the Points in a wrong order.

Is there a better way to do this?

Hello @roblen,
Welcome! Can you please share your 3rd script with Two Tasks?
And some input and output points to illustrate what you mean by

After a few minutes the second Task gets the Points in a wrong order.

along with your expected output?

Thank you,
Anais

Hey @roblen

I think you might be able to use clustering to do this. I do something similar with my stream tasks, wriiting to different databases at different points inthe script. Hopefully this link will help

Currently running this on Influx 1.5.2 and Kapacitor 1.5

Hey,
thank you for answering.

I had a bug in one UDF.

After fixing that bug, solution 2 solves my problem.