Help us shape the future of Go! Take the 2026 Go Developer Survey

influxdb

package
v4.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultAddress is the default address to which the InfluxDB client tries
	// to connect to.
	DefaultAddress = "localhost:8086"

	// DefaultDatabase is the default database used by the InfluxDB client.
	DefaultDatabase = "stats"

	// DefaultBufferSize is the default size for batches of metrics sent to
	// InfluxDB.
	DefaultBufferSize = 2 * 1024 * 1024 // 2 MB

	// DefaultTimeout is the default timeout value used when sending requests to
	// InfluxDB.
	DefaultTimeout = 5 * time.Second
)

Variables

This section is empty.

Functions

func AppendMeasure

func AppendMeasure(b []byte, t time.Time, m stats.Measure) []byte

AppendMeasure is a formatting routine to append the InflxDB line protocol representation of a measure to a memory buffer.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents an InfluxDB client that implements the stats.Handler interface.

func NewClient

func NewClient(addr string) *Client

NewClient creates and returns a new InfluxDB client publishing metrics to the server running at addr.

func NewClientWith

func NewClientWith(config ClientConfig) *Client

NewClientWith creates and returns a new InfluxDB client configured with the given config.

func (*Client) AppendMeasures

func (*Client) AppendMeasures(b []byte, time time.Time, measures ...stats.Measure) []byte

func (*Client) Close

func (c *Client) Close() error

Close flushes and closes the client, satisfies the io.Closer interface.

func (*Client) CreateDB

func (c *Client) CreateDB(db string) error

CreateDB creates a database named db in the InfluxDB server that the client was configured to send metrics to.

func (*Client) Flush

func (c *Client) Flush()

Flush satisfies the stats.Flusher interface.

func (*Client) HandleMeasures

func (c *Client) HandleMeasures(time time.Time, measures ...stats.Measure)

HandleMeasures satisfies the stats.Handler interface.

func (*Client) Write

func (s *Client) Write(b []byte) (n int, err error)

type ClientConfig

type ClientConfig struct {
	// Address of the InfluxDB database to send metrics to.
	Address string

	// Name of the InfluxDB database to send metrics to.
	Database string

	// Maximum size of batch of events sent to InfluxDB.
	BufferSize int

	// Maximum amount of time that requests to InfluxDB may take.
	Timeout time.Duration

	// Transport configures the HTTP transport used by the client to send
	// requests to InfluxDB. By default http.DefaultTransport is used.
	Transport http.RoundTripper
}

The ClientConfig type is used to configure InfluxDB clients.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL