loki

package
v1.30.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 19 Imported by: 0

README

Loki Output Plugin

This plugin sends logs to Loki, using metric name and tags as labels, log line will content all fields in key="value" format which is easily parsable with logfmt parser in Loki.

Logs within each stream are sorted by timestamp before being sent to Loki.

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

# A plugin that can transmit logs to Loki
[[outputs.loki]]
  ## The domain of Loki
  domain = "https://loki.domain.tld"

  ## Endpoint to write api
  # endpoint = "/loki/api/v1/push"

  ## Connection timeout, defaults to "5s" if not set.
  # timeout = "5s"

  ## Basic auth credential
  # username = "loki"
  # password = "pass"

  ## Additional HTTP headers
  # http_headers = {"X-Scope-OrgID" = "1"}

  ## If the request must be gzip encoded
  # gzip_request = false

  ## Optional TLS Config
  # tls_ca = "/etc/telegraf/ca.pem"
  # tls_cert = "/etc/telegraf/cert.pem"
  # tls_key = "/etc/telegraf/key.pem"

  ## Metric Name Label
  ## Label to use for the metric name to when sending metrics. If set to an
  ## empty string, this will not add the label. This is NOT suggested as there
  ## is no way to differentiate between multiple metrics.
  # metric_name_label = "__name"

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Log

type Log []string

type Loki

type Loki struct {
	Domain          string            `toml:"domain"`
	Endpoint        string            `toml:"endpoint"`
	Timeout         config.Duration   `toml:"timeout"`
	Username        config.Secret     `toml:"username"`
	Password        config.Secret     `toml:"password"`
	Headers         map[string]string `toml:"http_headers"`
	ClientID        string            `toml:"client_id"`
	ClientSecret    string            `toml:"client_secret"`
	TokenURL        string            `toml:"token_url"`
	Scopes          []string          `toml:"scopes"`
	GZipRequest     bool              `toml:"gzip_request"`
	MetricNameLabel string            `toml:"metric_name_label"`

	tls.ClientConfig
	// contains filtered or unexported fields
}

func (*Loki) Close

func (l *Loki) Close() error

func (*Loki) Connect

func (l *Loki) Connect() (err error)

func (*Loki) SampleConfig

func (*Loki) SampleConfig() string

func (*Loki) Write

func (l *Loki) Write(metrics []telegraf.Metric) error

type Request

type Request struct {
	Streams []Stream `json:"streams"`
}

type Stream

type Stream struct {
	Labels map[string]string `json:"stream"`
	Logs   []Log             `json:"values"`
}

type Streams

type Streams map[string]*Stream

func (Streams) MarshalJSON

func (s Streams) MarshalJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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