loki

package
v1.0.8 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLokiCore

func NewLokiCore(logConfig *conf.LogConfig) (zapcore.Core, error)

NewLokiCore create a new LokiCore

Types

type Client

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

Client is a client of loki

func NewLokiClient

func NewLokiClient(lokiAddr string) (*Client, error)

NewLokiClient create a new LokiClient

func (Client) GetLogs

func (c Client) GetLogs(ctx context.Context, selector string, start, end time.Time, limit uint32) ([]StreamWithLabels, error)

GetLogs get logs from loki

func (Client) SendLogs

func (c Client) SendLogs(ctx context.Context, request *logproto.PushRequest) error

SendLogs send logs to loki

type Core

type Core struct {
	SendLevel     zapcore.Level // default: zapCore.InfoLevel
	ContextFields []zapcore.Field
	URL           string
	// contains filtered or unexported fields
}

Core is a zap core for logging to loki

func (*Core) Check

Check determines whether the supplied Entry should be logged (using the embedded LevelEnabler and possibly some extra logic). If the entry should be logged, the Core adds itself to the CheckedEntry and returns the result.

Callers must use Check before calling Write.

func (*Core) Enabled

func (c *Core) Enabled(level zapcore.Level) bool

Enabled returns true if the given level is at or above this level.

func (*Core) Sync

func (c *Core) Sync() error

Sync flushes buffered logs (if any).

func (*Core) With

func (c *Core) With(fs []zapcore.Field) zapcore.Core

With adds structured context to the Core.

func (*Core) Write

func (c *Core) Write(entry zapcore.Entry, fs []zapcore.Field) error

Write serializes the Entry and any Fields supplied at the log site and writes them to their destination.

If called, Write should always log the Entry and Fields; it should not replicate the logic of Check.

type EntryWithLabels

type EntryWithLabels struct {
	Labels model.LabelSet
	logproto.Entry
}

EntryWithLabels is a log entry with labels.

type JSONRequest

type JSONRequest struct {
	Streams []JSONRequestStream `json:"streams,omitempty"`
}

JSONRequest is a json request for loki

type JSONRequestStream

type JSONRequestStream struct {
	Stream model.LabelSet         `json:"stream,omitempty"`
	Values []JSONRequestValueItem `json:"values,omitempty"`
}

JSONRequestStream contains the log within a JSONRequest

type JSONRequestValueItem

type JSONRequestValueItem []string

JSONRequestValueItem is an array of string

type StreamWithLabels

type StreamWithLabels struct {
	LabelSet model.LabelSet
	logproto.Stream
}

StreamWithLabels is a log stream with labels.

Jump to

Keyboard shortcuts

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