influxdb

package
v0.0.0-...-0e59cf9 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2020 License: MIT Imports: 21 Imported by: 0

README

InfluxDB v1.x Output Plugin

The InfluxDB output plugin writes metrics to the InfluxDB v1.x HTTP or UDP service.

Configuration:
# Configuration for sending metrics to InfluxDB
[[outputs.influxdb]]
  ## The full HTTP or UDP URL for your InfluxDB instance.
  ##
  ## Multiple URLs can be specified for a single cluster, only ONE of the
  ## urls will be written to each interval.
  # urls = ["unix:///var/run/influxdb.sock"]
  # urls = ["udp://127.0.0.1:8089"]
  # urls = ["http://127.0.0.1:8086"]

  ## The target database for metrics; will be created as needed.
  ## For UDP url endpoint database needs to be configured on server side.
  # database = "telegraf"

  ## The value of this tag will be used to determine the database.  If this
  ## tag is not set the 'database' option is used as the default.
  # database_tag = ""

  ## If true, the database tag will not be added to the metric.
  # exclude_database_tag = false

  ## If true, no CREATE DATABASE queries will be sent.  Set to true when using
  ## Telegraf with a user without permissions to create databases or when the
  ## database already exists.
  # skip_database_creation = false

  ## Name of existing retention policy to write to.  Empty string writes to
  ## the default retention policy.  Only takes effect when using HTTP.
  # retention_policy = ""

  ## Write consistency (clusters only), can be: "any", "one", "quorum", "all".
  ## Only takes effect when using HTTP.
  # write_consistency = "any"

  ## Timeout for HTTP messages.
  # timeout = "5s"

  ## HTTP Basic Auth
  # username = "telegraf"
  # password = "metricsmetricsmetricsmetrics"

  ## HTTP User-Agent
  # user_agent = "telegraf"

  ## UDP payload size is the maximum packet size to send.
  # udp_payload = "512B"

  ## Optional TLS Config for use on HTTP connections.
  # tls_ca = "/etc/telegraf/ca.pem"
  # tls_cert = "/etc/telegraf/cert.pem"
  # tls_key = "/etc/telegraf/key.pem"
  ## Use TLS but skip chain & host verification
  # insecure_skip_verify = false

  ## HTTP Proxy override, if unset values the standard proxy environment
  ## variables are consulted to determine which proxy, if any, should be used.
  # http_proxy = "http://corporate.proxy:3128"

  ## Additional HTTP headers
  # http_headers = {"X-Special-Header" = "Special-Value"}

  ## HTTP Content-Encoding for write request body, can be set to "gzip" to
  ## compress body or "identity" to apply no encoding.
  # content_encoding = "identity"

  ## When true, Telegraf will output unsigned integers as unsigned values,
  ## i.e.: "42u".  You will need a version of InfluxDB supporting unsigned
  ## integer values.  Enabling this option will result in field type errors if
  ## existing data has been written.
  # influx_uint_support = false

Documentation

Index

Constants

View Source
const (
	// DefaultMaxPayloadSize is the maximum length of the UDP data payload
	DefaultMaxPayloadSize = 512
)

Variables

View Source
var (
	ErrMissingURL = errors.New("missing URL")
)

Functions

func NewHTTPClient

func NewHTTPClient(config HTTPConfig) (*httpClient, error)

func NewUDPClient

func NewUDPClient(config UDPConfig) (*udpClient, error)

Types

type APIError

type APIError struct {
	StatusCode  int
	Title       string
	Description string
}

APIError is a general error reported by the InfluxDB server

func (APIError) Error

func (e APIError) Error() string

type Client

type Client interface {
	Write(context.Context, []telegraf.Metric) error
	CreateDatabase(ctx context.Context, database string) error
	Database() string
	URL() string
	Close()
}

type Conn

type Conn interface {
	Write(b []byte) (int, error)
	Close() error
}

type DatabaseNotFoundError

type DatabaseNotFoundError struct {
	APIError
	Database string
}

type Dialer

type Dialer interface {
	DialContext(ctx context.Context, network, address string) (Conn, error)
}

type HTTPConfig

type HTTPConfig struct {
	URL                  *url.URL
	UserAgent            string
	Timeout              time.Duration
	Username             string
	Password             string
	TLSConfig            *tls.Config
	Proxy                *url.URL
	Headers              map[string]string
	ContentEncoding      string
	Database             string
	DatabaseTag          string
	ExcludeDatabaseTag   bool
	RetentionPolicy      string
	Consistency          string
	SkipDatabaseCreation bool

	InfluxUintSupport bool `toml:"influx_uint_support"`
	Serializer        *influx.Serializer
	Log               telegraf.Logger
}

type InfluxDB

type InfluxDB struct {
	URL                  string   // url deprecated in 0.1.9; use urls
	URLs                 []string `toml:"urls"`
	Username             string
	Password             string
	Database             string
	DatabaseTag          string `toml:"database_tag"`
	ExcludeDatabaseTag   bool   `toml:"exclude_database_tag"`
	UserAgent            string
	RetentionPolicy      string
	WriteConsistency     string
	Timeout              internal.Duration
	UDPPayload           internal.Size     `toml:"udp_payload"`
	HTTPProxy            string            `toml:"http_proxy"`
	HTTPHeaders          map[string]string `toml:"http_headers"`
	ContentEncoding      string            `toml:"content_encoding"`
	SkipDatabaseCreation bool              `toml:"skip_database_creation"`
	InfluxUintSupport    bool              `toml:"influx_uint_support"`
	tls.ClientConfig

	Precision string // precision deprecated in 1.0; value is ignored

	CreateHTTPClientF func(config *HTTPConfig) (Client, error)
	CreateUDPClientF  func(config *UDPConfig) (Client, error)

	Log telegraf.Logger
	// contains filtered or unexported fields
}

InfluxDB struct is the primary data structure for the plugin

func (*InfluxDB) Close

func (i *InfluxDB) Close() error

func (*InfluxDB) Connect

func (i *InfluxDB) Connect() error

func (*InfluxDB) Description

func (i *InfluxDB) Description() string

func (*InfluxDB) SampleConfig

func (i *InfluxDB) SampleConfig() string

func (*InfluxDB) Write

func (i *InfluxDB) Write(metrics []telegraf.Metric) error

Write sends metrics to one of the configured servers, logging each unsuccessful. If all servers fail, return an error.

type QueryResponse

type QueryResponse struct {
	Results []QueryResult `json:"results"`
}

QueryResponse is the response body from the /query endpoint

func (QueryResponse) Error

func (r QueryResponse) Error() string

type QueryResult

type QueryResult struct {
	Err string `json:"error,omitempty"`
}

type UDPConfig

type UDPConfig struct {
	MaxPayloadSize int
	URL            *url.URL
	Serializer     *influx.Serializer
	Dialer         Dialer
	Log            telegraf.Logger
}

type WriteResponse

type WriteResponse struct {
	Err string `json:"error,omitempty"`
}

WriteResponse is the response body from the /write endpoint

func (WriteResponse) Error

func (r WriteResponse) Error() string

Jump to

Keyboard shortcuts

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