Skip to content

Instantly share code, notes, and snippets.

@xNok
Created September 13, 2021 00:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xNok/e00c6c5b8a7164f3274f1fc8c1132b73 to your computer and use it in GitHub Desktop.
Save xNok/e00c6c5b8a7164f3274f1fc8c1132b73 to your computer and use it in GitHub Desktop.
func write_event_with_line_protocol(client influxdb2.Client, t ThermostatSetting) {
// get non-blocking write client
writeAPI := client.WriteAPI(org, bucket)
// write line protocol
writeAPI.WriteRecord(fmt.Sprintf("thermostat,unit=temperature,user=%s avg=%f,max=%f", t.user, t.avg, t.max))
// Flush writes
writeAPI.Flush()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment