loki

package
v0.0.0-...-b14f0d7 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAX_ERR_MESSAGE_LEN     = 1024
	DEFAULT_BATCH_MAX_SIZE  = 10
	DEFAULT_BATCH_MAX_WAIT  = 10 * time.Second
	DEFAULT_REQUEST_TIMEOUT = 30 * time.Second
	DEFAULT_REQUEST_PROTO   = GrpcRequestProto
)
View Source
const (
	ERROR_STREAM_LIMIT_EXCEED = "streams: %d exceeds limit: %d, stream: '%s'"
)

Variables

This section is empty.

Functions

func NewBatch

func NewBatch[T BatchRequest](maxStreamConfig int, labels map[string]string, entries ...push.Entry) T

Types

type Authentication

type Authentication interface {
	Apply(req *http.Request)
}

func NewAuth

func NewAuth(uname, pass string) Authentication

type BasicAuthentication

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

func (*BasicAuthentication) Apply

func (b *BasicAuthentication) Apply(req *http.Request)

type BatchRequest

type BatchRequest interface {
	Add(push.Entry) error
	Compose(context context.Context, url string) (*http.Request, int, error)
	Size() int
	Reset()
	// contains filtered or unexported methods
}

type Client

type Client interface {
	WithLabels(map[string]string) Client
	Name() string
	Chan() chan<- push.Entry
	Stop()
}

Client pushes entries to Loki and can be stopped

func NewClient

func NewClient(cfg Config, ctx context.Context) (Client, error)

type Config

type Config struct {
	Url             string           // Push Url of the loki server including http:// or https://, ex: https://example.com/loki/api/v1/push
	BatchMaxSize    int              // BatchMaxSize is the maximum number of log lines that are sent in one request. Default: 5
	BatchMaxWait    time.Duration    // BatchMaxWait is the maximum time to wait before sending a request. Default: 10s
	Timeout         time.Duration    // Request timeout. Default: 30s
	RequestProtocol LokiRequestProto // Http or grpc. Default: grpc

	Logger Logger

	// Static labels that are added to all log lines.
	Labels map[string]string

	// Dynamic labels that are extracted from log fields, and add to log line as Structure Metadata.
	// Useful when using with logger, ex: log.Info("message", "log_field1", "val1", "log_field2", "val2")
	// The Key is required, but the Value is fallback when extracted field is empty and it is optional.
	StructuredMetadata map[string]string

	// Basic Auth
	Username string
	Password string
}

func NewWithDefaultConfig

func NewWithDefaultConfig(cfg Config) (*Config, error)

func (*Config) Apply

func (c *Config) Apply(conf Config) (*Config, error)

func (*Config) Validate

func (c *Config) Validate() bool

type GrpcBatchRequest

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

func (GrpcBatchRequest) Add

func (b GrpcBatchRequest) Add(entry push.Entry) error

add an entry to the batch

func (*GrpcBatchRequest) Compose

func (r *GrpcBatchRequest) Compose(context context.Context, url string) (req *http.Request, entriesCount int, err error)

func (GrpcBatchRequest) Reset

func (b GrpcBatchRequest) Reset()

func (GrpcBatchRequest) Size

func (b GrpcBatchRequest) Size() int

type HttpBatchRequest

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

func (HttpBatchRequest) Add

func (b HttpBatchRequest) Add(entry push.Entry) error

add an entry to the batch

func (*HttpBatchRequest) Compose

func (r *HttpBatchRequest) Compose(context context.Context, url string) (req *http.Request, entriesCount int, err error)

func (HttpBatchRequest) Reset

func (b HttpBatchRequest) Reset()

func (HttpBatchRequest) Size

func (b HttpBatchRequest) Size() int

type LogHandler

type LogHandler func()

type Logger

type Logger interface {
	Error(string)
}

type LokiRequestProto

type LokiRequestProto string
const (
	GrpcRequestProto LokiRequestProto = "grpc"
	HttpRequestProto LokiRequestProto = "http"
)

type NoAuth

type NoAuth struct{}

func (*NoAuth) Apply

func (n *NoAuth) Apply(req *http.Request)

type NoLogger

type NoLogger struct{}

func (*NoLogger) Error

func (l *NoLogger) Error(e string)

type Requesthandler

type Requesthandler func()

Jump to

Keyboard shortcuts

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