loki

package module
v0.0.0-...-c7e79ea Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: MIT Imports: 13 Imported by: 0

README

Loki

Client

GoDoc

Log pushing client library for Loki using subpackage from official repository (https://github.com/grafana/loki/tree/main/pkg/push)

This library supports both JSON and Protobuf payloads.

Slog

GoDoc

Includes an experimental loki slog handler, import as

    import (
        lokislog "github.com/royalcat/loki/slog"
    )

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Log(ts time.Time, msg string, lables, metadata map[string]string)
	Flush(ctx context.Context)
	Shutdown(ctx context.Context)
}

func NewClient

func NewClient(endpoint string, o *ClientOptions) (Client, error)

Creates a loki client for v1 api with automatic batching. Endpoint example http://localhost:3100/loki/api/v1/push Options can be nil for default values

type ClientOptions

type ClientOptions struct {
	// Default labels passed with each message
	DefaultLabels map[string]string

	// Max wait before sending batch
	BatchWait time.Duration
	// Max batch size
	BatchSize uint

	// Callback what called on every error occurred in sender.
	// Due to asynchronous nature of sender errors cant be suppied with return values/
	ErrorCallback func(err error)

	// by default uses http.DefaultClient
	HTTPClient HTTPClient

	// User json instead of protobuf for log pushing
	UseJSON bool
}

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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