grpc

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

Documentation

Index

Constants

View Source
const (
	DefaultBatchWait            = 1 * time.Second
	DefaultBatchSize        int = 1024 * 1024
	DefaultMinBackoff           = 500 * time.Millisecond
	DefaultMaxBackoff           = 5 * time.Minute
	DefaultMaxRetries       int = 10
	DefaultTimeout              = 10 * time.Second
	DefaultKeepAlive            = 30 * time.Second
	DefaultKeepAliveTimeout     = 5 * time.Second
)

Default configuration values for GRPC client

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

Variables

View Source
var (
	UserAgent = fmt.Sprintf("loki-grpc-client/%s", version.Version)
)

Functions

This section is empty.

Types

type Client

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

Client for pushing logs via GRPC

func New

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

New creates a new GRPC client from config

func NewWithSendCallbacks

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

New creates a new GRPC client from config and send callbacks

func (*Client) Handle

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

Handle implements 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 {
	// Server address (host:port)
	ServerAddress string `yaml:"server_address"`

	// Batching configuration
	BatchWait time.Duration `yaml:"batch_wait"`
	BatchSize int           `yaml:"batch_size"`

	// Connection configuration
	Timeout time.Duration `yaml:"timeout"`

	// TLS configuration (uses Prometheus common TLSConfig for consistency)
	TLS promConfig.TLSConfig `yaml:"tls"`

	// Keep alive configuration
	KeepAlive        time.Duration `yaml:"keep_alive"`
	KeepAliveTimeout time.Duration `yaml:"keep_alive_timeout"`

	// Retry configuration
	BackoffConfig backoff.Config `yaml:"backoff_config"`

	// Labels to add to any time series when communicating with loki
	ExternalLabels labelutil.LabelSet `yaml:"external_labels,omitempty"`

	// Tenant ID for multi-tenant mode (empty string means single tenant)
	TenantID string `yaml:"tenant_id"`
}

Config describes configuration for a GRPC pusher client.

func NewDefaultConfig

func NewDefaultConfig(serverAddress string) (Config, error)

NewDefaultConfig creates a default configuration for a given GRPC server address.

func (*Config) BuildDialOptions

func (c *Config) BuildDialOptions() ([]grpc.DialOption, error)

BuildDialOptions creates GRPC dial options from the configuration

func (*Config) RegisterFlags

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

RegisterFlags registers configuration flags

func (*Config) RegisterFlagsWithPrefix

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

RegisterFlagsWithPrefix registers flags with a given prefix

func (*Config) UnmarshalYAML

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

UnmarshalYAML implements YAML unmarshaler

Jump to

Keyboard shortcuts

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