loki

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: 16 Imported by: 0

README

Loki Output Plugin

This plugin sends logs to Loki, using 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.

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     string            `toml:"username"`
	Password     string            `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) Description

func (l *Loki) Description() string

func (*Loki) SampleConfig

func (l *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