http

package
v0.0.0-...-ae02d81 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BatchWait      = 1 * time.Second
	BatchSize  int = 1024 * 1024
	MinBackoff     = 500 * time.Millisecond
	MaxBackoff     = 5 * time.Minute
	MaxRetries int = 10
	Timeout        = 10 * time.Second
)

NOTE the helm chart for promtail and fluent-bit also have defaults for these values, please update to match if you make changes here.

View Source
const (

	// Label reserved to override the tenant ID while processing
	// pipeline stages
	ReservedLabelTenantID = "__tenant_id__"
)

Variables

View Source
var (
	// TODO: Check if changing agent is safe
	UserAgent = fmt.Sprintf("promtail/%s", version.Version)
)

Functions

This section is empty.

Types

type Client

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

Client for pushing logs in snappy-compressed protos over HTTP.

func New

func New(cfg *Config) (*Client, error)

New makes a new http Client from config

func NewWithSendCallbacks

func NewWithSendCallbacks(cfg *Config, onSend callbacks.Send) (*Client, error)

New makes a new http client from config and send callbacks

func (*Client) Handle

func (c *Client) Handle(ls model.LabelSet, t time.Time, s string) error

Handle implement EntryHandler; adds a new line to the next batch; send is async.

func (*Client) Stop

func (c *Client) Stop()

Stop the client.

type Config

type Config struct {
	URL       urlutil.URLValue
	BatchWait time.Duration
	BatchSize int

	Client config.HTTPClientConfig `yaml:",inline"`

	BackoffConfig backoff.Config `yaml:"backoff_config"`
	// The labels to add to any time series or alerts when communicating with loki
	ExternalLabels labelutil.LabelSet `yaml:"external_labels,omitempty"`
	Timeout        time.Duration      `yaml:"timeout"`

	// The tenant ID to use when pushing logs to Loki (empty string means
	// single tenant mode)
	TenantID string `yaml:"tenant_id"`

	// EnableKeepAlives lets the client reuse TCP connections between pushes.
	// Off by default: cycling connections lets a load balancer in front of
	// Loki redistribute traffic instead of pinning it to a few backends.
	// Worth enabling when small batches push the request rate high enough
	// that per-request TCP/TLS handshakes become measurable.
	EnableKeepAlives bool `yaml:"enable_keep_alives"`
}

Config describes configuration for a HTTP pusher client.

func NewDefaultConfig

func NewDefaultConfig(url string) (Config, error)

NewDefaultConfig creates a default configuration for a given target Loki URL.

func (*Config) RegisterFlags

func (c *Config) RegisterFlags(flags *flag.FlagSet)

RegisterFlags registers flags.

func (*Config) RegisterFlagsWithPrefix

func (c *Config) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet)

RegisterFlags with prefix registers flags where every name is prefixed by prefix. If prefix is a non-empty string, prefix should end with a period.

func (*Config) UnmarshalYAML

func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implement Yaml Unmarshaler

Jump to

Keyboard shortcuts

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