This project correspond to a Warp 10 UDF to load GTS from Influx-DB databases.
This function takes the following parameters as entry: an influxDB user, his password, the influxDB url, the database, a column map and an influx query. The column map correspond to the column from the result table generated by the query. Timestamp and class field are mandatory. For each key, associate the position, or the column name in the InfluxDB table (Starting from 0). For the class and the labels keys, the value correspond to a map with the position or column name (in InfluxDB) as key, and the wanted name in Warp10 as value. Using NULL here as value, then the same name than the Influx one is kept.
For the timestamp key using NULL, will result in loading the column "time" of InfluxDB. Latitude and longitude must contains values of type Double. Elevation can be Long or Double but will be rounded to the nearest Long.
Here a small example is given.
'http://localhost:8086' // URL
'user' // Influx user
'pwd' // Password
'mydb' // Database
// A map
{
// GTS timestamps corresponds to the values of the 1st column of the result query
'timestamp' 0
// One GTS will be generated for each following class
'class'
{
// An idle GTS wich will have the same values than the "idle" column of the Influx result
'idle' 'idle'
// A cpu GTS, that will have the values of the 5th column of the Influx result
4 'cpu'
}
// Those GTS will have the following labels (tags)
'labels'
{
// A server label corresponding to the column "host" of the Influx result
'host' 'server'
// A serie label corresponding to the 2nd column of the Influx result
1 'serie'
// A status label corresponding to the column "status" of the Influx result
'status' NULL
}
// GTS elevations corresponds to the values of the 6th column of the result query
'elevation' 5
// GTS latitudes corresponds to the values of the "lat" column of the result query
'latitude' 'lat'
// GTS latitudes corresponds to the values of the "long" column of the result query
'longitude' 'long'
}
// A query
'SELECT * FROM table'
'io.warp10.influxdb.LOADFROMINFLUX' UDF
Build this project, and then add the generated jar in Warp 10 server.
Clone this repository then execute the following command to build a jar.
gradle shadowJar
Open the Warp 10 conf file where you have to configure the following parameters to add a directory containing your udf on the Warp10 platform. Then copy the jar generated by gradle in warpscript.jars.directory.
warpscript.jars.directory = /some/dir/udf
warpscript.jars.refresh = 60000