loki

package
v1.4.34 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package loki provides bounded, scoped read-only Loki queries for interactive tools.

Index

Constants

View Source
const MaximumLimit = 100
View Source
const MaximumOffset = 1000

Variables

View Source
var ErrInvalidArgument = errors.New("loki: invalid argument")
View Source
var ErrInvalidConfig = errors.New("loki: invalid configuration")
View Source
var ErrResponseTooLarge = errors.New("loki: response too large")
View Source
var ErrUnsupportedScope = errors.New("loki: configured query is not a selector-only scope")

Functions

This section is empty.

Types

type DiscoveryRequest

type DiscoveryRequest struct {
	Label, Search string
	Offset, Limit int
}

type DiscoveryResult

type DiscoveryResult struct {
	Labels     []string `json:"labels"`
	Count      int      `json:"count"`
	Offset     int      `json:"offset"`
	Limit      int      `json:"limit"`
	NextOffset int      `json:"next_offset,omitempty"`
	Truncated  bool     `json:"truncated"`
	Truncation []string `json:"truncation,omitempty"`
}

type Policy

type Policy struct {
	MaxRows, MaxFields, MaxBytes int
	MaxLookback, Timeout         time.Duration
}

func ToolPolicy

func ToolPolicy() Policy

type ReadRequest

type ReadRequest struct {
	// Forward selects the oldest records first; the default remains newest first.
	Forward         bool
	PrefixLabels    map[string]string
	Labels          map[string]string
	Service, Search string
	Lookback        time.Duration
	Offset, Limit   int
}

type ReadResult

type ReadResult struct {
	Records    []Record `json:"records"`
	Count      int      `json:"count"`
	Offset     int      `json:"offset"`
	Limit      int      `json:"limit"`
	NextOffset int      `json:"next_offset,omitempty"`
	Truncated  bool     `json:"truncated"`
	Truncation []string `json:"truncation,omitempty"`
}

type Record

type Record struct {
	Timestamp time.Time         `json:"timestamp"`
	Message   string            `json:"message"`
	Labels    map[string]string `json:"labels"`
}

type Service

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

func NewService

func NewService(cfg config.AgentLokiSourceConfig, scrubber core.Scrubber) (*Service, error)

NewService constructs an isolated read transport; it does not change the ingestion client.

func (*Service) Discover

func (service *Service) Discover(ctx context.Context, request DiscoveryRequest) (DiscoveryResult, error)

func (*Service) DiscoveryAvailable

func (service *Service) DiscoveryAvailable() bool

DiscoveryAvailable is true when scope can be enforced by the series endpoint.

func (*Service) Read

func (service *Service) Read(ctx context.Context, request ReadRequest) (ReadResult, error)

func (*Service) ReadWindow added in v1.4.32

func (service *Service) ReadWindow(ctx context.Context, request ReadRequest, from, to time.Time) (ReadResult, error)

Jump to

Keyboard shortcuts

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