client

package
v2.10.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResultTypeStream = "streams"
)

ResultType values

Variables

View Source
var TailPerReadDeadline = 30 * time.Second

The websocket reader does not respect the context while reading, so we set an explicit deadline for each read. It's OK if no log lines show up in this interval, the read will be silently retried if this deadline is reached and the context is still alive. This is a variable so tests can set this to something short and end as soon as they are ready to end.

Functions

This section is empty.

Types

type Client

type Client struct {
	Address string
}

Client holds configuration for the loki

func (*Client) QueryConfig added in v2.10.0

func (c *Client) QueryConfig(ctx context.Context) (map[string]any, error)

func (*Client) QueryRange

func (c *Client) QueryRange(ctx context.Context, queryStr string, limit int, start, end time.Time, direction string, step, interval time.Duration, quiet bool) (*QueryResponse, error)

QueryRange queries Loki in a given time range.

func (*Client) Tail added in v2.10.0

func (c *Client) Tail(ctx context.Context, start time.Time, query string, cb func(*TailChunk) error) error

Tail watches a Loki query until the provided context is canceled. The start time should be as close as possible to the present time; you can get some historical logs through this API, but logs will be missed while that query is running on the loki side. So it's best to call QueryRange up to the current timestamp, and then pass the most recent timestamp that call received to Tail. This function will always return an error; if you canceled the context on purpose you should ignore the error context.Canceled.

type Entry

type Entry struct {
	Timestamp time.Time
	Line      string
}

Entry represents a log entry. It includes a log message and the time it occurred at. From: https://github.com/grafana/loki/blob/d9380eaac950c669864c0af60fd99eae281d2438/pkg/loghttp/entry.go

type LabelSet

type LabelSet map[string]string

LabelSet is a key/value pair mapping of labels From: https://github.com/grafana/loki/blob/d9380eaac950c669864c0af60fd99eae281d2438/pkg/loghttp/labels.go

type QueryResponse

type QueryResponse struct {
	Status string            `json:"status"`
	Data   QueryResponseData `json:"data"`
}

QueryResponse represents the http json response to a Loki range and instant query From: https://github.com/grafana/loki/blob/a9d85de4aa5290cf2f8b2dca5d08645bbd0dc66c/pkg/loghttp/query.go

type QueryResponseData

type QueryResponseData struct {
	ResultType ResultType  `json:"resultType"`
	Result     ResultValue `json:"result"`
}

QueryResponseData represents the http json response to a label query From: https://github.com/grafana/loki/blob/a9d85de4aa5290cf2f8b2dca5d08645bbd0dc66c/pkg/loghttp/query.go

func (*QueryResponseData) UnmarshalJSON

func (q *QueryResponseData) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface. From: https://github.com/grafana/loki/blob/a9d85de4aa5290cf2f8b2dca5d08645bbd0dc66c/pkg/loghttp/query.go

type ResultType

type ResultType string

ResultType holds the type of the result

type ResultValue

type ResultValue interface {
	Type() ResultType
}

ResultValue interface mimics the promql.Value interface From: https://github.com/grafana/loki/blob/a9d85de4aa5290cf2f8b2dca5d08645bbd0dc66c/pkg/loghttp/query.go

type Stream

type Stream struct {
	Labels  LabelSet `json:"stream"`
	Entries []Entry  `json:"values"`
}

Stream represents a log stream. It includes a set of log entries and their labels. From: https://github.com/grafana/loki/blob/a9d85de4aa5290cf2f8b2dca5d08645bbd0dc66c/pkg/loghttp/query.go

type TailChunk added in v2.10.0

type TailChunk struct {
	Time   time.Time         // The time of the messages.
	Fields map[string]string // Any loki fields attached to the messages.
	Lines  []string          // The text of the messages.
}

TailChunk is a set of log lines retrieved via Loki's tail API. Each line occurred at the same time and has the same associated fields.

Jump to

Keyboard shortcuts

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