InfluxDB With GoLang

Viewed 56

I'm very new to InfluxDB and seem to be having some trouble understanding how to use the Go client. I'm currently using the default example code but I can't understand where to find the data that is being uploaded, or if it is being uploaded at all. The current code looks like

package main

import (
    "context"
    "fmt"
    "time"

    influxdb2 "github.com/influxdata/influxdb-client-go/v2"
)

func main() {

    token := "tokenInsertedHere"

    fmt.Println("testing influxdb")
    // Create a new client using an InfluxDB server base URL and an authentication token
    client := influxdb2.NewClient("http://localhost:8086", token)
    // Use blocking write client for writes to desired bucket
    writeAPI := client.WriteAPIBlocking("orgName", "bucketName")
    // Create point using full params constructor
    p := influxdb2.NewPoint("test",
        map[string]string{"unit": "temperature"},
        map[string]interface{}{"avg": 24.5, "max": 45.0},
        time.Now())
    // write point immediately
    writeAPI.WritePoint(context.Background(), p)
    client.Close()
}

When I'm on the data explorer page filtering measurements in the bucket the code should've wrote to, the measurement doesn't pop up. What am I doing wrong? I've noticed that the client doesn't throw any errors, which is strange to me. I've tried using a fake token and it acts like there were no problems when writing to the db. Would appreciate any help!

0 Answers
Related