loki

package
v0.74.0 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2025 License: BSD-3-Clause Imports: 17 Imported by: 0

README

Loki output

It sends the logs batches to Loki using HTTP API.

Supports dead queue.

Config params

address string required

A full URI address of Loki

Example address

http://127.0.0.1:3100 or https://loki:3100


labels []Label

Array of labels to send logs

Example labels

label=value


message_field string required

Message field from log to be mapped to loki

Example

message


timestamp_field string required

Timestamp field from log to be mapped to loki

Example

timestamp


auth AuthConfig

Auth config.

AuthConfig params:

  • strategy describes strategy to use; options:"disabled|tenant|basic|bearer" By default strategy is disabled.
  • tenant_id should be provided if strategy is tenant.
  • username should be provided if strategy is basic. Username is used for HTTP Basic Authentication.
  • password should be provided if strategy is basic. Password is used for HTTP Basic Authentication.
  • bearer_token should be provided if strategy is bearer. Token is used for HTTP Bearer Authentication.

tls_enabled bool default=false

If set true, the plugin will use SSL/TLS connections method.


tls_skip_verify bool default=false

If set, the plugin will skip SSL/TLS verification.


request_timeout cfg.Duration default=1s

Client timeout when sends requests to Loki HTTP API.


connection_timeout cfg.Duration default=5s

It defines how much time to wait for the connection.


keep_alive KeepAliveConfig

Keep-alive config.

KeepAliveConfig params:

  • max_idle_conn_duration - idle keep-alive connections are closed after this duration. By default idle connections are closed after 10s.
  • max_conn_duration - keep-alive connections are closed after this duration. If set to 0 - connection duration is unlimited. By default connection duration is 5m.

workers_count cfg.Expression default=gomaxprocs*4

How much workers will be instantiated to send batches. It also configures the amount of minimum and maximum number of database connections.


batch_size cfg.Expression default=capacity/4

Maximum quantity of events to pack into one batch.


batch_size_bytes cfg.Expression default=0

A minimum size of events in a batch to send. If both batch_size and batch_size_bytes are set, they will work together.


batch_flush_timeout cfg.Duration default=200ms

After this timeout batch will be sent even if batch isn't completed.


retention cfg.Duration default=1s

Retention milliseconds for retry to Loki.


retry int default=10

Retries of insertion. If File.d cannot insert for this number of attempts, File.d will fall with non-zero exit code or skip message (see fatal_on_failed_insert).


fatal_on_failed_insert bool default=false

After an insert error, fall with a non-zero exit code or not. A configured deadqueue disables fatal exits.


retention_exponentially_multiplier int default=2

Multiplier for exponential increase of retention between retries



Generated using insane-doc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Factory

func Factory() (pipeline.AnyPlugin, pipeline.AnyConfig)

Types

type AuthConfig

type AuthConfig struct {
	// > AuthStrategy.Strategy describes strategy to use.
	Strategy  string `json:"strategy" default:"disabled" options:"disabled|tenant|basic|bearer"`
	Strategy_ AuthStrategy

	// > TenantID for Tenant Authentication.
	TenantID string `json:"tenant_id"`

	// > Username for HTTP Basic Authentication.
	Username string `json:"username"`

	// > Password for HTTP Basic Authentication.
	Password string `json:"password"`

	// > Token for HTTP Bearer Authentication.
	BearerToken string `json:"bearer_token"`
}

! config-params ^ config-params

type AuthStrategy

type AuthStrategy byte
const (
	StrategyDisabled AuthStrategy = iota
	StrategyTenant
	StrategyBasic
	StrategyBearer
)

type Config

type Config struct {
	// > @3@4@5@6
	// >
	// > A full URI address of Loki
	// >
	// > Example address
	// >
	// > http://127.0.0.1:3100 or https://loki:3100
	Address string `json:"address" required:"true"` // *

	// > @3@4@5@6
	// >
	// > Array of labels to send logs
	// >
	// > Example labels
	// >
	// > label=value
	Labels []Label `json:"labels" slice:"true"` // *

	// > @3@4@5@6
	// >
	// > Message field from log to be mapped to loki
	// >
	// > Example
	// >
	// > message
	MessageField string `json:"message_field" required:"true"` // *

	// > @3@4@5@6
	// >
	// > Timestamp field from log to be mapped to loki
	// >
	// > Example
	// >
	// > timestamp
	TimestampField string `json:"timestamp_field" required:"true"` // *

	// > @3@4@5@6
	// >
	// > Auth config.
	// >
	// > `AuthConfig` params:
	// > * `strategy` describes strategy to use; options:"disabled|tenant|basic|bearer"
	// > By default strategy is `disabled`.
	// > * `tenant_id` should be provided if strategy is `tenant`.
	// > * `username` should be provided if strategy is `basic`.
	// > Username is used for HTTP Basic Authentication.
	// > * `password` should be provided if strategy is `basic`.
	// > Password is used for HTTP Basic Authentication.
	// > * `bearer_token` should be provided if strategy is `bearer`.
	// > Token is used for HTTP Bearer Authentication.
	Auth AuthConfig `json:"auth" child:"true"` // *

	// > @3@4@5@6
	// >
	// > If set true, the plugin will use SSL/TLS connections method.
	TLSEnabled bool `json:"tls_enabled" default:"false"` // *

	// > @3@4@5@6
	// >
	// > If set, the plugin will skip SSL/TLS verification.
	TLSSkipVerify bool `json:"tls_skip_verify" default:"false"` // *

	// > @3@4@5@6
	// >
	// > Client timeout when sends requests to Loki HTTP API.
	RequestTimeout  cfg.Duration `json:"request_timeout" default:"1s" parse:"duration"` // *
	RequestTimeout_ time.Duration

	// > @3@4@5@6
	// >
	// > It defines how much time to wait for the connection.
	ConnectionTimeout  cfg.Duration `json:"connection_timeout" default:"5s" parse:"duration"` // *
	ConnectionTimeout_ time.Duration

	// > @3@4@5@6
	// >
	// > Keep-alive config.
	// >
	// > `KeepAliveConfig` params:
	// > * `max_idle_conn_duration` - idle keep-alive connections are closed after this duration.
	// > By default idle connections are closed after `10s`.
	// > * `max_conn_duration` - keep-alive connections are closed after this duration.
	// > If set to `0` - connection duration is unlimited.
	// > By default connection duration is `5m`.
	KeepAlive KeepAliveConfig `json:"keep_alive" child:"true"` // *

	// > @3@4@5@6
	// >
	// > How much workers will be instantiated to send batches.
	// > It also configures the amount of minimum and maximum number of database connections.
	WorkersCount  cfg.Expression `json:"workers_count" default:"gomaxprocs*4" parse:"expression"` // *
	WorkersCount_ int

	// > @3@4@5@6
	// >
	// > Maximum quantity of events to pack into one batch.
	BatchSize  cfg.Expression `json:"batch_size" default:"capacity/4"  parse:"expression"` // *
	BatchSize_ int

	// > @3@4@5@6
	// >
	// > A minimum size of events in a batch to send.
	// > If both batch_size and batch_size_bytes are set, they will work together.
	BatchSizeBytes  cfg.Expression `json:"batch_size_bytes" default:"0" parse:"expression"` // *
	BatchSizeBytes_ int

	// > @3@4@5@6
	// >
	// > After this timeout batch will be sent even if batch isn't completed.
	BatchFlushTimeout  cfg.Duration `json:"batch_flush_timeout" default:"200ms" parse:"duration"` // *
	BatchFlushTimeout_ time.Duration

	// > @3@4@5@6
	// >
	// > Retention milliseconds for retry to Loki.
	Retention  cfg.Duration `json:"retention" default:"1s" parse:"duration"` // *
	Retention_ time.Duration

	// > @3@4@5@6
	// >
	// > Retries of insertion. If File.d cannot insert for this number of attempts,
	// > File.d will fall with non-zero exit code or skip message (see fatal_on_failed_insert).
	Retry int `json:"retry" default:"10"` // *

	// > @3@4@5@6
	// >
	// > After an insert error, fall with a non-zero exit code or not. A configured deadqueue disables fatal exits.
	FatalOnFailedInsert bool `json:"fatal_on_failed_insert" default:"false"` // *

	// > @3@4@5@6
	// >
	// > Multiplier for exponential increase of retention between retries
	RetentionExponentMultiplier int `json:"retention_exponentially_multiplier" default:"2"` // *
}

! config-params ^ config-params

type KeepAliveConfig

type KeepAliveConfig struct {
	// Idle keep-alive connections are closed after this duration.
	MaxIdleConnDuration  cfg.Duration `json:"max_idle_conn_duration" parse:"duration" default:"10s"`
	MaxIdleConnDuration_ time.Duration

	// Keep-alive connections are closed after this duration.
	MaxConnDuration  cfg.Duration `json:"max_conn_duration" parse:"duration" default:"5m"`
	MaxConnDuration_ time.Duration
}

type Label

type Label struct {
	Label string `json:"label" required:"true"`
	Value string `json:"value" required:"true"`
}

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

func (*Plugin) Out

func (p *Plugin) Out(event *pipeline.Event)

func (*Plugin) Start

func (p *Plugin) Start(config pipeline.AnyConfig, params *pipeline.OutputPluginParams)

func (*Plugin) Stop

func (p *Plugin) Stop()

Jump to

Keyboard shortcuts

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