Kent,

There are a few ways this can be done:

1. Use the snapshot feature to load/store your weights. The moving_avg 
example here 
<https://github.com/influxdata/kapacitor/blob/master/udf/agent/examples/moving_avg/moving_avg.go>
 is 
a good place to start. There are a few gotchas with this approach, changing 
your TICKscript will invalidate the snapshot and require that you generate 
a new one. Snapshots cannot be externally defined or read. They must be 
generated from within the UDF, which creates a bit of a chicken and the egg 
problem.

2. Manage loading and storing weights within the UDF such that it is opaque 
to Kapacitor. Basically like you suggest, either pass a file path as a 
parameter to the UDF to load during the init phase or possibly an InfluxDB 
measurement. Using a local file will be simplest approach to get you going 
but requires that the weights file be deployed with the UDF binary :(

In short we recognize that this is a generic need for UDFs and we want to 
solve it within Kapacitor itself, and the snapshots feature was an initial 
attempt at that. But its short comings cripple it enough that I would 
recommend not trying to use it in its current state. We have already put 
together an design doc for how we want this to work in the future, you can 
find it here 
<https://github.com/influxdata/kapacitor/blob/master/BLOB_STORE_DESIGN.md>. 

For now I recommend going with option 2. This way you have control over the 
weights and using an InfluxDB measurement could work well for this case 
since the weights are inherently a series. Or if you have some other 
distributed storage available to you, you could leverage that to store and 
load the weights, eliminating the need to deploy the weights along side the 
UDF binary.

Let me know if I can clarify anything more.
Nathaniel

On Wednesday, November 23, 2016 at 9:46:41 AM UTC-7, [email protected] wrote:
>
> I would like to implement a UDF for Kapacitor providing a weighted moving 
> average, which means I need to be able to initialize the UDF with its array 
> of weights (not necessarily a small array). Other than initializing the 
> weights, the rest of the function is similar to the moving_avg example.
>
> At this point, my crucial bit of missing code is figuring out how best to 
> communicate to my UDF what its weights should be. I can imagine passing a 
> simple parameter pointing to a file, or a key to look up the data in a 
> measurement in influxdb, but I would like expert advice on the right way to 
> approach the problem.
>
> TIA
> Kent
>
>

-- 
Remember to include the version number!
--- 
You received this message because you are subscribed to the Google Groups 
"InfluxData" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
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/fd847b7d-e59a-44c8-acb5-f62b7739d6b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to