InfluxDB Sink

The sink will publish the result into a InfluxDB.

Compile & deploy plugin

Please make following update before compile the plugin,

  • Add Influxdb library reference in go.mod.
  • Remove the first line // +build plugins of file plugins/sinks/influx.go.
  1. # cd $kuiper_src
  2. # go build -trimpath --buildmode=plugin -o plugins/sinks/Influx.so plugins/sinks/influx/influx.go
  3. # zip influx.zip plugins/sinks/Influx.so
  4. # cp influx.zip /root/tomcat_path/webapps/ROOT/
  5. # bin/kuiper create plugin sink influx -f /tmp/influxPlugin.txt
  6. # bin/kuiper create rule influx -f /tmp/influxRule.txt

Restart the Kuiper server to activate the plugin.

Properties

Property nameOptionalDescription
addrtrueThe addr of the InfluxDB
measurementtrueThe measurement of the InfluxDb (like table name)
usernamefalseThe InfluxDB login username
passwordfalseThe InfluxDB login password
databasenametrueThe database of the InfluxDB
tagkeytrueThe tag key of the InfluxDB
tagvaluetrueThe tag value of the InfluxDB
fieldstrueThe column of the InfluxDB,split with “,”

Sample usage

Below is a sample for selecting temperature great than 50 degree, and some profiles only for your reference.

/tmp/influxRule.txt

  1. {
  2. "id": "influx",
  3. "sql": "SELECT * from demo_stream where temperature > 50",
  4. "actions": [
  5. {
  6. "log": {},
  7. "influx":{
  8. "addr": "http://192.168.100.245:8086",
  9. "username": "",
  10. "password": "",
  11. "measurement": "test",
  12. "databasename": "databasename",
  13. "tagkey": "tagkey",
  14. "tagvalue": "tagvalue",
  15. "fields": "humidity,temperature,pressure"
  16. }
  17. }
  18. ]
  19. }

/tmp/influxPlugin.txt

  1. {
  2. "file":"http://localhost:8080/influx.zip"
  3. }

plugins/go.mod

  1. module plugins
  2. go 1.14
  3. require (
  4. github.com/emqx/kuiper v0.0.0-20200323140757-60d00241372b
  5. github.com/influxdata/influxdb-client-go v1.2.0
  6. github.com/influxdata/influxdb1-client v0.0.0-20200515024757-02f0bf5dbca3 // indirect
  7. )
  8. replace github.com/emqx/kuiper => /root/goProject/kuiper