lokiutil

package
v2.12.1 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package lokiutil provides utilities for working with Loki.

TODO: document.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QueryRange

func QueryRange(ctx context.Context, c *loki.Client, queryStr string, from, through time.Time, follow bool, f func(t time.Time, line string) error) error

QueryRange calls QueryRange on the passed loki.Client and calls f with each logline.

func RepairLine added in v2.11.0

func RepairLine(line string) (resultLine string, resultJSON map[string]any)

RepairLine takes a log line from a potentially-misconfigured Loki instance and returns the actual logged text. If the logged text is JSON, the parsed text is returned as well. Downstream consumers expecting JSON should not attempt an additional parse of the returned line.

The misconfiguration is where promtail is told the lines are Docker JSON, but they're actually CRI text, or promtail is told the lines are CRI plain text, but are actually Docker JSON. In these cases, promtail just sends whatever is in the file that it's tailing instead of just the message. (It's likely that stdout/stderr information is lost in this case as well, and we don't attempt to recover that, since we don't typically care.)

Types

type FakeServer added in v2.10.0

type FakeServer struct {
	Entries     []loki.Entry // Must be sorted by time ascending.
	Page        int          // Keep track of the current page.
	SleepAtPage int          // Which page to put the server to sleep. 0 means don't sleep.
}

func (*FakeServer) ServeHTTP added in v2.10.0

func (l *FakeServer) ServeHTTP(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis
Package client provides a Loki client.
Package client provides a Loki client.
Package testloki needs to be documented.
Package testloki needs to be documented.

Jump to

Keyboard shortcuts

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