influxdb

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package influxdb exposes an opencensus stats exporter for influxdb.

It may be used to store opencensus metrics in an influxdb database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Exporter

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

Exporter is an opencensus exporter for Influxdb

func NewExporter

func NewExporter(opts ...Option) *Exporter

NewExporter creates a new Influxdb exporter.

Use options to configure:

  • an influxdd.Store instance, configured with the desired settings
  • an error handler. If set to nil, a no-op handler is set by default
  • a map of custom tags for written records (may be nil)

func (*Exporter) ExportView

func (e *Exporter) ExportView(viewData *view.Data)

ExportView sends collected metrics to the backend sink

type MetricPoint

type MetricPoint struct {
	Measurement string
	Tags        map[string]string
	Fields      map[string]interface{}
	Timestamp   time.Time
}

MetricPoint represents a single row in a batch of measurements

type Option

type Option func(*Exporter)

Option configures an exporter

func WithErrorHandler

func WithErrorHandler(h func(error)) Option

WithErrorHandler sets an error handler for this exporter

func WithStore

func WithStore(s Store) Option

WithStore sets the influxdb store for this exporter

func WithTags

func WithTags(tags map[string]string) Option

WithTags sets or adds some tags to every record posted to the store

type Store

type Store interface {
	Database() string
	GetClient() influxdb.Client
	Ping(context.Context, time.Duration) error
	ReadMetrics(context.Context, string) (*influxdb.Response, error)
	WriteMetrics(context.Context, string, map[string]string, map[string]interface{}) error
	WriteBatch(context.Context, []MetricPoint) error
}

Store provides an access to an influxdb database for reading and writing metrics

func NewStore

func NewStore(opts ...StoreOption) (Store, error)

NewStore builds an instance of Store with some options

type StoreOption

type StoreOption func(*influxDB)

StoreOption configures an influxdb client

func WithAddr

func WithAddr(addr string) StoreOption

WithAddr sets the influxdb server URL

func WithDatabase

func WithDatabase(db string) StoreOption

WithDatabase sets the database to use

func WithInsecureSkipVerify

func WithInsecureSkipVerify(skip bool) StoreOption

WithInsecureSkipVerify toggles TLS server certificate check by the client

func WithMapper

func WithMapper(mapper func(string, map[string]string) (string, map[string]string)) StoreOption

WithMapper specifies a name mapping function, which translates a measurement name and a set of tags into another one. This allows for converting measurement names into tags and reduce the number of time series handled by influxdb.

func WithNameAsTag

func WithNameAsTag(timeseries string) StoreOption

WithNameAsTag is a helper which specifies a simple mapper converting a measurement name into a "metric" tag and the time series name is predefined.

func WithPassword

func WithPassword(pwd string) StoreOption

WithPassword sets the database password to connect to an influxdb database

func WithProxy

func WithProxy(proxy func(*http.Request) (*url.URL, error)) StoreOption

WithProxy configures a proxy for the http client

func WithTLSConfig

func WithTLSConfig(config *tls.Config) StoreOption

WithTLSConfig sets TLS configuration for an https client

func WithTimeout

func WithTimeout(d time.Duration) StoreOption

WithTimeout sets write timeouts for the client

func WithURL

func WithURL(r string) StoreOption

WithURL combines user, password and host address in one single URI notation (e.g. http://user:password@host:port)

func WithUser

func WithUser(user string) StoreOption

WithUser sets the database user to connect to an influxdb database

Jump to

Keyboard shortcuts

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