Hi,
I just tested it and got it to run with a little go-programm.
First I did the port forwarding for the virtual ctrlX CORE, which I mentioned in a post above. Then I installed the InfluxDB App on my ctrlX CORE virtual (V1.20). I created a Organisation and a Bucket in the influxDB. Then I created a api-token and copied it out.
I used the influxdb-client-go from github in my App Build Environment. See this code. First I write a value to influx, then I do a quirie on this:
package main
import (
"context"
"fmt"
"time"
influxdb2 "github.com/influxdata/influxdb-client-go/v2"
)
const (
//please insert your organisation, token and bucket here (do the settings prior in influxdb webinterface)
myToken = "xxxxxxxxx..." //create a token in influx and paste it in here
myOrg = "Boschrexroth" // your organisation name (setting in influxDB)
myBucket = "TestBucket" // your bucket name (setting in influxDB)
)
func main() {
// Create a new client using an InfluxDB server base URL and an authentication token
InfluxDBclient := influxdb2.NewClient("http://10.0.2.2:8086", myToken)
// write to disired organisation an bucket
writeAPI := InfluxDBclient.WriteAPIBlocking(myOrg, myBucket)
// Create a point in influx
p := influxdb2.NewPointWithMeasurement("metric").
//AddTag("unit", "temperature").
AddField("sampleValue", 40.2).
SetTime(time.Now())
writeAPI.WritePoint(context.Background(), p)
// Get query client
queryAPI := InfluxDBclient.QueryAPI(myOrg)
// Get parser flux query result
result, err := queryAPI.Query(context.Background(), `from(bucket:"TestBucket")|> range(start: -1h) |> filter(fn: (r) => r._measurement == "metric")`)
if err == nil {
fmt.Printf("row: %s\n", result.Record().String())
}
// Ensures background processes finishes
InfluxDBclient.Close()
}
... View more