loki

package
v0.1.2-dev Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLokiOutPut

func SetLokiOutPut()

func WithErrorCallback

func WithErrorCallback(errorHandler func(err error)) clientOption

func WithSendBatchSize

func WithSendBatchSize(batchSize uint) clientOption

func WithSendBatchTimeout

func WithSendBatchTimeout(sendTimeout time.Duration) clientOption

Types

type Client

type Client interface {
	Logf(format string, e *logrus.Entry)
	LogfWithLabels(labels map[string]string, format []string)

	Ping() (*PongResponse, error)
	Close()
}

func NewClient

func NewClient(exchanger StreamsExchanger, labels map[string]string, options ...clientOption) (Client, error)

Creates a Promtail client with a custom Streams exchanger

NOTE: options are applied before client start

func NewJSONv1Client

func NewJSONv1Client(lokiAddress string, defaultLabels map[string]string, options ...clientOption) (Client, error)

type LogEntry

type LogEntry struct {
	Timestamp time.Time
	Format    string
}

type LogStream

type LogStream struct {
	Labels  map[string]string
	Entries []*LogEntry
}

type PongResponse

type PongResponse struct {
	IsReady bool
}

type PromtailHook

type PromtailHook struct {
	logrus.Hook
	// contains filtered or unexported fields
}

func NewPromtailHook

func NewPromtailHook(lokiURL string, labels map[string]string) (*PromtailHook, error)

Initializes a Promtail hook for Logrus logger.

  • lokiAddress - address of Grafana Loki server to push logs to (e.g. loki:3100)
  • labels - is kinda tags for grepping in Loki's and Grafana's queries

func (*PromtailHook) Fire

func (rcv *PromtailHook) Fire(entry *logrus.Entry) error

func (*PromtailHook) Levels

func (rcv *PromtailHook) Levels() []logrus.Level

func (*PromtailHook) LokiHealthCheck

func (rcv *PromtailHook) LokiHealthCheck() error

type StreamsExchanger

type StreamsExchanger interface {
	Push(streams []*LogStream) error
	Ping() (*PongResponse, error)
}

func NewJSONv1Exchanger

func NewJSONv1Exchanger(lokiAddress string) StreamsExchanger

Creates a client with direct send logic (nor batch neither queue) capable to exchange with Loki v1 API via JSON

Read more at: https://github.com/grafana/loki/blob/master/docs/api.md#post-lokiapiv1push

Jump to

Keyboard shortcuts

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