influxdb

package
v1.30.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 22 Imported by: 185

README

InfluxDB v1.x Output Plugin

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

Global configuration options

In addition to the plugin-specific configuration settings, plugins support additional global and plugin configuration settings. These settings are used to modify metrics, tags, and field or create aliases and configure ordering, etc. See the CONFIGURATION.md for more details.

Secret-store support

This plugin supports secrets from secret-stores for the username and password option. See the secret-store documentation for more details on how to use them.

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

To send every metrics into multiple influxdb, define additional [[outputs.influxdb]] section with new urls.

Metrics

Reference the influx serializer for details about metric production.

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

func NewHTTPClient(cfg 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                  config.Secret
	Password                  config.Secret
	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 {
	URLs                      []string          `toml:"urls"`
	Username                  config.Secret     `toml:"username"`
	Password                  config.Secret     `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"`
	Precision                 string            `toml:"precision" deprecated:"1.0.0;option is ignored"`
	Log                       telegraf.Logger   `toml:"-"`
	tls.ClientConfig

	CreateHTTPClientF func(config *HTTPConfig) (Client, error)
	CreateUDPClientF  func(config *UDPConfig) (Client, error)
	// 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) SampleConfig

func (*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 QueryResponseError added in v1.25.0

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

QueryResponseError is the response body from the /query endpoint

func (QueryResponseError) Error added in v1.25.0

func (r QueryResponseError) 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 WriteResponseError added in v1.25.0

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

WriteResponseError is the response body from the /write endpoint

func (WriteResponseError) Error added in v1.25.0

func (r WriteResponseError) Error() string

Jump to

Keyboard shortcuts

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