loki

package
v1.26.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: MIT Imports: 17 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"

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"`

	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