KapacitorLoopback

I’m trying to get this function to work properly, it says it is outputing, but there is nothing in the measurement.

dbrp “cacti_metrics”.“autogen”

var ospf = stream
|from()
.database(‘cacti_metrics’)
.retentionPolicy(‘autogen’)
.measurement(‘ospf’)
.groupBy(*)
ospf
|kapacitorLoopback()
.database(‘cacti_metrics_temp’)
.retentionPolicy(‘autogen’)
.measurement(‘ospf’)

If I change the database back to ‘cacti_metrics’ (which is what I really want) it fails with a loop detected.

I can do what I’m trying to do without using this function, but it loops (as expected) and ramps the CPU up.

I was hoping this function was to solve that issue.

Hi ,
what happens if you use

|kapacitorLoopback()
.database(‘cacti_metrics’)
.retentionPolicy(‘autogen’)
.measurement(‘ospf_temp’)

Have a nice weekend !

That also fails with loop detected.

Have a good weekend as well :slight_smile:

Hi , it is expected behaviour that there is nothing in the measurement ,
the KapacitorLoopbackNode does not write anything in the database but it writes data back tot the kapacitor stream.

I hope to see some examples or feedback from people who have used this node …

From the documentation :

The kapacitorLoopback node writes data back into the Kapacitor stream. To write data to a remote Kapacitor instance use the InfluxDBOutNode.

Hi , this link made it clear to me …

https://github.com/influxdata/kapacitor/pull/1360

The first node in a tick script is always a stream node or a batch node , it is the start of the pipeline.
The kapacitorloopbacknode sends the data back to the beginning of the pipeline .
It acts like a wile true loop .
If you do that you must find a way to exit the loop, else an infinite loop is detected.

The example in the link exits the loop with a log() node when the desired tolerante is achieved…

var tolerance = 0.0001
var sq = stream
|from()
.measurement(‘m’)
|eval(lambda: 0.5 * (“x” + (“s” / “x”)))
.as(‘xn’)
.keep()

sq|where(lambda: abs(“x” - “xn”) < tolerance)
|log()

sq|where(lambda: abs(“x” - “xn”) > tolerance)
|eval(lambda: “xn”)
.as(‘x’)
.keep(‘s’,‘x’)
|kapacitorLoopback()
.database(‘mydb2’)
.retentionPolicy(‘autogen’)

The documentation says :
The kapacitorLoopback node writes data back into the Kapacitor stream. To write data to a remote Kapacitor instance use the [InfluxDBOutNode]

You should read it as :
The kapacitorLoopback node writes data back into the beginning of the Kapacitor stream. To write data to a remote Kapacitor instance use the [InfluxDBOutNode]

Thanks for that.

I was misinterpreting the function, thinking it sent the data back into the original Measurement - updating or replacing the older data.

The reason I was looking into this is because we’re using a Subscription from one node to backup data on another node.

The streaming data is duplicating one of the fields/tags as a null - yea, nulls are not supposed to exist with InfluxDB but we’re getting them.

Had to go with a different methodology.