influxdb

package
v1.20.2 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2021 License: MIT Imports: 21 Imported by: 185

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 included in the written 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 = ""

  ## The value of this tag will be used to determine the retention policy.  If this
  ## tag is not set the 'retention_policy' option is used as the default.
  # retention_policy_tag = ""

  ## If true, the 'retention_policy_tag' will not be included in the written metric.
  # exclude_retention_policy_tag = false

  ## 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 = "gzip"

  ## 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
Metrics

Reference the influx serializer for details about metric production.

Documentation

Overview

nolint

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 added in v1.14.0

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

func NewUDPClient added in v1.14.0

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

Types

type APIError added in v1.14.0

type APIError struct {
	StatusCode  int
	Title       string
	Description string
}

APIError is a general error reported by the InfluxDB server

func (APIError) Error added in v1.14.0

func (e APIError) Error() string

type Client added in v1.14.0

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

type Conn added in v1.14.0

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

type DatabaseNotFoundError added in v1.14.0

type DatabaseNotFoundError struct {
	APIError
	Database string
}

type Dialer added in v1.14.0

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

type HTTPConfig added in v1.14.0

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
	RetentionPolicyTag        string
	ExcludeRetentionPolicyTag bool
	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            `toml:"username"`
	Password                  string            `toml:"password"`
	Database                  string            `toml:"database"`
	DatabaseTag               string            `toml:"database_tag"`
	ExcludeDatabaseTag        bool              `toml:"exclude_database_tag"`
	RetentionPolicy           string            `toml:"retention_policy"`
	RetentionPolicyTag        string            `toml:"retention_policy_tag"`
	ExcludeRetentionPolicyTag bool              `toml:"exclude_retention_policy_tag"`
	UserAgent                 string            `toml:"user_agent"`
	WriteConsistency          string            `toml:"write_consistency"`
	Timeout                   config.Duration   `toml:"timeout"`
	UDPPayload                config.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 added in v1.14.0

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

QueryResponse is the response body from the /query endpoint

func (QueryResponse) Error added in v1.14.0

func (r QueryResponse) Error() string

type QueryResult added in v1.14.0

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

type UDPConfig added in v1.14.0

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

type WriteResponse added in v1.14.0

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

WriteResponse is the response body from the /write endpoint

func (WriteResponse) Error added in v1.14.0

func (r WriteResponse) Error() string

Jump to

Keyboard shortcuts

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