influxdb_v2_listener

package
v1.32.2 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 22 Imported by: 0

README

InfluxDB V2 Listener Input Plugin

InfluxDB V2 Listener is a service input plugin that listens for requests sent according to the InfluxDB HTTP API. The intent of the plugin is to allow Telegraf to serve as a proxy/router for the /api/v2/write endpoint of the InfluxDB HTTP API.

The /api/v2/write endpoint supports the precision query parameter and can be set to one of ns, us, ms, s. All other parameters are ignored and defer to the output plugins configuration.

Telegraf minimum version: Telegraf 1.16.0

Service Input

This plugin is a service input. Normal plugins gather metrics determined by the interval setting. Service plugins start a service to listens and waits for metrics or events to occur. Service plugins have two key differences from normal plugins:

  1. The global or plugin specific interval setting may not apply
  2. The CLI options of --test, --test-wait, and --once may not produce output for this plugin

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 token option. See the secret-store documentation for more details on how to use them.

Configuration

# Accept metrics over InfluxDB 2.x HTTP API
[[inputs.influxdb_v2_listener]]
  ## Address and port to host InfluxDB listener on
  ## (Double check the port. Could be 9999 if using OSS Beta)
  service_address = ":8086"

  ## Maximum undelivered metrics before rate limit kicks in.
  ## When the rate limit kicks in, HTTP status 429 will be returned.
  ## 0 disables rate limiting
  # max_undelivered_metrics = 0

  ## Maximum duration before timing out read of the request
  # read_timeout = "10s"
  ## Maximum duration before timing out write of the response
  # write_timeout = "10s"

  ## Maximum allowed HTTP request body size in bytes.
  ## 0 means to use the default of 32MiB.
  # max_body_size = "32MiB"

  ## Optional tag to determine the bucket.
  ## If the write has a bucket in the query string then it will be kept in this tag name.
  ## This tag can be used in downstream outputs.
  ## The default value of nothing means it will be off and the database will not be recorded.
  # bucket_tag = ""

  ## Set one or more allowed client CA certificate file names to
  ## enable mutually authenticated TLS connections
  # tls_allowed_cacerts = ["/etc/telegraf/clientca.pem"]

  ## Add service certificate and key
  # tls_cert = "/etc/telegraf/cert.pem"
  # tls_key = "/etc/telegraf/key.pem"

  ## Optional token to accept for HTTP authentication.
  ## You probably want to make sure you have TLS configured above for this.
  # token = "some-long-shared-secret-token"

  ## Influx line protocol parser
  ## 'internal' is the default. 'upstream' is a newer parser that is faster
  ## and more memory efficient.
  # parser_type = "internal"

Metrics

Metrics are created from InfluxDB Line Protocol in the request body.

Troubleshooting

Example Query:

curl -i -XPOST 'http://localhost:8186/api/v2/write' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'

Example Output

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BadRequestCode

type BadRequestCode string

The BadRequestCode constants keep standard error messages see: https://v2.docs.influxdata.com/v2.0/api/#operation/PostWrite

type InfluxDBV2Listener

type InfluxDBV2Listener struct {
	ServiceAddress string `toml:"service_address"`

	common_tls.ServerConfig

	MaxUndeliveredMetrics int             `toml:"max_undelivered_metrics"`
	ReadTimeout           config.Duration `toml:"read_timeout"`
	WriteTimeout          config.Duration `toml:"write_timeout"`
	MaxBodySize           config.Size     `toml:"max_body_size"`
	Token                 config.Secret   `toml:"token"`
	BucketTag             string          `toml:"bucket_tag"`
	ParserType            string          `toml:"parser_type"`

	Log telegraf.Logger `toml:"-"`
	// contains filtered or unexported fields
}

func (*InfluxDBV2Listener) Gather

func (*InfluxDBV2Listener) Init

func (h *InfluxDBV2Listener) Init() error

func (*InfluxDBV2Listener) SampleConfig

func (*InfluxDBV2Listener) SampleConfig() string

func (*InfluxDBV2Listener) ServeHTTP

func (h *InfluxDBV2Listener) ServeHTTP(res http.ResponseWriter, req *http.Request)

func (*InfluxDBV2Listener) Start

func (*InfluxDBV2Listener) Stop

func (h *InfluxDBV2Listener) Stop()

Jump to

Keyboard shortcuts

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