Categorygithub.com/influxdata/influxdb1-client
modulepackage
0.0.0-20220302092344-a9ab5670611c
Repository: https://github.com/influxdata/influxdb1-client.git
Documentation: pkg.go.dev

# README

influxdb1-clientv2

influxdb1-clientv2 is the current Go client API for InfluxDB 1.x. For connecting to InfluxDB 2.x see the influxdb-client-go client library.

InfluxDB is an open-source distributed time series database, find more about InfluxDB at https://docs.influxdata.com/influxdb/latest

Usage

To import into your Go project, run the following command in your terminal: go get github.com/influxdata/influxdb1-client/v2 Then, in your import declaration section of your Go file, paste the following: import "github.com/influxdata/influxdb1-client/v2"

If you get the error build github.com/user/influx: cannot find module for path github.com/influxdata/influxdb1-client/v2 when trying to build: change your import to:

import(
	_ "github.com/influxdata/influxdb1-client" // this is important because of the bug in go mod
	client "github.com/influxdata/influxdb1-client/v2"
)

Example

The following example creates a new client to the InfluxDB host on localhost:8086 and runs a query for the measurement cpu_load from the mydb database.

func ExampleClient_query() {
	c, err := client.NewHTTPClient(client.HTTPConfig{
		Addr: "http://localhost:8086",
	})
	if err != nil {
		fmt.Println("Error creating InfluxDB Client: ", err.Error())
	}
	defer c.Close()

	q := client.NewQuery("SELECT count(value) FROM cpu_load", "mydb", "")
	if response, err := c.Query(q); err == nil && response.Error() == nil {
		fmt.Println(response.Results)
	}
}

# Packages

Package models implements basic objects used throughout the TICK stack.
No description provided by the author
Package client (v2) is the current official Go client for InfluxDB.

# Functions

EpochToTime takes a unix epoch time and uses precision to return back a time.Time.
NewChunkedResponse reads a stream and produces responses from the stream.
NewClient will instantiate and return a connected client to issue commands to the server.
NewConfig will create a config to be used in connecting to the client.
ParseConnectionString will parse a string to create a valid connection URL.
SetPrecision will round a time to the specified precision.

# Constants

ConsistencyAll requires all data nodes to acknowledge a write.
ConsistencyAny allows for hinted hand off, potentially no write happened yet.
ConsistencyOne requires at least one data node acknowledged a write.
ConsistencyQuorum requires a quorum of data nodes to acknowledge a write.
DefaultHost is the default host used to connect to an InfluxDB instance.
DefaultPort is the default port used to connect to an InfluxDB instance.
DefaultTimeout is the default connection timeout used to connect to an InfluxDB instance.

# Structs

BatchPoints is used to send batched data in a single write.
ChunkedResponse represents a response from the server that uses chunking to stream the output.
Client is used to make calls to the server.
Config is used to specify what server to connect to.
Message represents a user message.
Point defines the fields that will be written to the database Measurement, Time, and Fields are required Precision can be specified if the time is in epoch format (integer).
Query is used to send a command to the server.
Response represents a list of statement results.
Result represents a resultset returned from a single statement.