Categorygithub.com/influxdata/influxdb-client-go
modulepackage
0.2.0
Repository: https://github.com/influxdata/influxdb-client-go.git
Documentation: pkg.go.dev

# README

influxdb-client-go

A home for InfluxDB’s 2.x's golang client. This client is not compatible with InfluxDB 1.x--if you are looking for the 1.x golang client you can find it here.

Example:

influx, err := influxdb.New(myHTTPInfluxAddress, myToken, influxdb.WithHTTPClient(myHTTPClient))
if err != nil {
	panic(err) // error handling here; normally we wouldn't use fmt but it works for the example
}

// we use client.NewRowMetric for the example because it's easy, but if you need extra performance
// it is fine to manually build the []client.Metric{}.
myMetrics := []influxdb.Metric{
	influxdb.NewRowMetric(
		map[string]interface{}{"memory": 1000, "cpu": 0.93},
		"system-metrics",
		map[string]string{"hostname": "hal9000"},
		time.Date(2018, 3, 4, 5, 6, 7, 8, time.UTC)),
	influxdb.NewRowMetric(
		map[string]interface{}{"memory": 1000, "cpu": 0.93},
		"system-metrics",
		map[string]string{"hostname": "hal9000"},
		time.Date(2018, 3, 4, 5, 6, 7, 9, time.UTC)),
}

// The actual write..., this method can be called concurrently.
if _, err := influx.Write(context.Background(), "my-awesome-bucket", "my-very-awesome-org", myMetrics...); err != nil {
	log.Fatal(err) // as above use your own error handling here.
}
influx.Close() // closes the client.  After this the client is useless.

Releases

We will be using git-flow style releases, the current stable release will be listed in the master readme.

Requirements

influxdb-client-go requires go version 1.12 or newer to build.

# Packages

Code generated for client DO NOT EDIT.
Package writer contains useful types for buffering, batching and periodically syncing writes onto a provided metric writing client.

# Functions

HTTPClientWithTLSConfig returns an *http.Client with sane timeouts and the provided TLSClientConfig.
New creates a new Client.
NewRowMetric creates a *RowMetric from tags, fields and a timestamp.
WithGZIP returns an option for setting gzip compression level.
WithHTTPClient returns an option for setting a custom HTTP Client.
WithMaxLineBytes returns an option for setting the max length of a line of influx line-protocol in bytes.
WithNoCompression returns an option for writing the data to influxdb without compression.
WithUserAgent returns an option for setting a custom useragent string.
WithUserAndPass returns an option for setting a username and password, which generates a session for use.
WithV1Config is an option for setting config in a way that makes it easy to convert from the old influxdb1 client config.

# Constants

action cannot be performed.
Error code constants copied from influxdb.
Error code constants copied from influxdb.
Error code constants copied from influxdb.
validation failed.
Error code constants copied from influxdb.
Error code constants copied from influxdb.
Error code constants copied from influxdb.
Error code constants copied from influxdb.
Error code constants copied from influxdb.
data type is correct, but out of range.

# Variables

ErrUnimplemented is an error for when pieces of the client's functionality is unimplemented.

# Structs

Client is a client for writing to influx.
Error is an error returned by a client operation It contains a number of contextual fields which describe the nature and cause of the error.
HTTPConfig is an https://github.com/influxdata/influxdb1-client compatible client for setting config options.
Option is an option for the client config.
QueryCSVResult is the result of a flux query in CSV format.
RowMetric is a Metric, that has methods to make it easy to add tags and fields.
SetupRequest is a request to setup a new influx instance.
SetupResult is the result of setting up a new influx instance.

# Type aliases

Field is just a github.com/influxdata/line-protocol.Field.
Metric is just a github.com/influxdata/line-protocol.Metric.
Tag is just a github.com/influxdata/line-protocol.Tag.