influxdata / kapacitor

Open source framework for processing, monitoring, and alerting on time series data
MIT License
2.31k stars 492 forks source link

passing multiple parameters from tick script to python UDF without json structure #1446

Open ChandanKundu opened 7 years ago

ChandanKundu commented 7 years ago

I have implemented tick script with multiple parameters using json like structure. Now I want to implement the same thing without considering the json concept. Please help me in this regard.

nathanielc commented 7 years ago

@ChandanKundu I am not sure what you are trying to accomplish. Can you provide some broader context? What are you trying to do with passing multiple parameters to the UDF? Do these parameters vary per data point? Or are they static for the lifetime of a UDF?

ChandanKundu commented 7 years ago

Dear Nathaniel,

Thank you very much for showing interest on my question. My objective is to perform k-means clustering in UDF (python) in batch mode. The user will select the variable names along with number of clusters in runtime. As per my knowledge, it is not possible to select variable names from kapacitor( if possible, please give me suggestion). Therefore, the user will use one UI to select name of variables and number of clusters. I have used json like structure that will be read by python UDF to perform clustering. Now, my question is, is there any other options that can be used to achieve the same. Thanks once again.

Thanks & Regards.

Chandan


Chandan KunduSr. Data ScientistDSI,Usha Martin TechnologiesPS Srijan Tech Park, DN 52, Sector V, 4th Floor, Salt Lake City, Kolkata 700091, IndiaMob No.-7685823604.

nathanielc commented 7 years ago

A UDF can declare the options it needs to initialize. An example TICKscript using a kmeans UDF could look like this.

batch
   |query('...')
   @kmeans()
      .numClusters(3)
      .fieldName('value')

If you want those options to be configurable per task use vars and templates.

var field_name = 'value'
var num_clusters = 3

batch
   |query('...')
   @kmeans()
      .numClusters(num_clusters)
      .fieldName(field_name)
sinfergit commented 3 years ago

@nathanielc Can we pass multiple fields to the python UDF function? I have a requirement to pass temperature,humidity and pressure fields, created in different measurements such as in temp measurement humidity measurement to the python function to do a fault detection & diagnosis using a Keras model.