logslurp

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2021 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogStream

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

A LogStream is used to parse a log given a StreamConfig.

func NewLogStream

func NewLogStream(rd io.RuneReader, config *StreamConfig) (*LogStream, error)

NewLogStream returns a new instance of LogStream.

func (*LogStream) Read

func (s *LogStream) Read() (*PushRequestStream, error)

Read returns the next log entry wrapped in a PushRequestStream so that it can retain the labels.

type PushRequest

type PushRequest struct {
	Streams []*PushRequestStream `json:"streams"`
}

PushRequest is a message that can be sent to /loki/api/v1/push.

This is documented at https://github.com/grafana/loki/blob/master/docs/api.md#post-lokiapiv1push

func NewPushRequest

func NewPushRequest(streams []*PushRequestStream) *PushRequest

NewPushRequest returns a PushRequest given a list of PushRequestStream objects. This groups the streams by their labels so that the final payload is smaller.

type PushRequestStream

type PushRequestStream struct {
	Stream map[string]string         `json:"stream"`
	Values []*PushRequestStreamEntry `json:"values"`
}

A PushRequestStream is a stream of timestamp/log line values in ascending timestamp order, plus stream labels in key/value pair format.

func (*PushRequestStream) String

func (s *PushRequestStream) String() string

type PushRequestStreamEntry

type PushRequestStreamEntry struct {
	Timestamp time.Time
	Line      string
}

A PushRequestStreamEntry is a timestamp/log line value pair.

func (*PushRequestStreamEntry) MarshalJSON

func (e *PushRequestStreamEntry) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of the PushRequestStreamEntry.

func (*PushRequestStreamEntry) String

func (e *PushRequestStreamEntry) String() string

type StreamConfig

type StreamConfig struct {
	Path            string            `json:"path"`
	Labels          map[string]string `json:"labels"`
	RegexpString    string            `json:"regexp"`
	TimestampLayout string            `json:"timestamp_layout"`
}

StreamConfig represents an entry for one stream.

type Tail

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

Tail is a ReadCloser

func NewTail

func NewTail(name string, off int64, log log15.Logger) (*Tail, error)

NewTail opens a file at the specified offset and provides an io.Reader interface to the file, tail(1)-style: if the file is moved and recreated (maybe due to a log rotation), this transparently reopens the file and keeps the stream open.

This means that the calls to Read() will never return EOF, unless Stop() is called.

func (*Tail) Close

func (t *Tail) Close() (finalErr error)

Close frees any resources from the Tail instance.

func (*Tail) Inode

func (t *Tail) Inode() uint64

Inode returns the inode of the currently opened file.

func (*Tail) Offset

func (t *Tail) Offset() int64

Offset returns the current offset of the file.

func (*Tail) Read

func (t *Tail) Read(p []byte) (n int, err error)

func (*Tail) Stop

func (t *Tail) Stop()

Stop immediately stops reading from the file. This causes EOF to be returned from Read().

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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