loki

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultFieldMappingConfig = logs.FieldMappingConfig{
	Severity: []string{"detected_level"},
	Host:     []string{"pod"},
}

Functions

func New

func New(conn connection.Loki, mappingConfig *logs.FieldMappingConfig) *lokiSearcher

Types

type Data

type Data struct {
	ResultType string         `json:"resultType"`
	Stats      map[string]any `json:"stats"`

	// Logs per label (aka. stream)
	Result []Result `json:"result"`
}

Data holds the actual query results and statistics.

type DroppedEntry

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

DroppedEntry represents entries that were not included in the stream

type Request

type Request struct {
	logs.LogsRequestBase `json:",inline" template:"true"`

	// Query is the LogQL query to perform
	Query string `json:"query,omitempty" template:"true"`

	// Since is a duration used to calculate start relative to end.
	// If end is in the future, start is calculated as this duration before now.
	// Any value specified for start supersedes this parameter.
	Since string `json:"since,omitempty"`

	// Step is the Query resolution step width in duration format or float number of seconds
	Step string `json:"step,omitempty"`

	// Only return entries at (or greater than) the specified interval, can be a duration format or float number of seconds
	Interval string `json:"interval,omitempty"`

	// Direction is the direction of the query. "forward" or "backward" (default)
	Direction string `json:"direction,omitempty"`
}

Request represents available parameters for Loki queries.

+kubebuilder:object:generate=true

func (*Request) DeepCopy

func (in *Request) DeepCopy() *Request

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Request.

func (*Request) DeepCopyInto

func (in *Request) DeepCopyInto(out *Request)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*Request) Params

func (r *Request) Params() url.Values

Params returns the URL query parameters for the Loki request

type Response

type Response struct {
	Status    string       `json:"status"`
	Data      Data         `json:"data"`
	ErrorType v1.ErrorType `json:"errorType,omitempty"`
	Error     string       `json:"error,omitempty"`
}

Response represents the top-level response from Loki's query_range API.

func (*Response) ToLogResult

func (t *Response) ToLogResult(mappingConfig logs.FieldMappingConfig) logs.LogResult

type Result

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

type StreamItem

type StreamItem struct {
	LogLine *logs.LogLine
	Error   error
}

type StreamRequest

type StreamRequest struct {
	// Query is the LogQL query to perform
	Query string `json:"query,omitempty" template:"true"`

	// DelayFor is the number of seconds to delay retrieving logs (default 0, max 5)
	DelayFor int `json:"delayFor,omitempty"`

	// Limit is the maximum number of entries to return per stream in the initial response when connecting (default 100).
	// This only affects historical entries sent immediately upon connection, not the ongoing stream of new entries.
	Limit int `json:"limit,omitempty"`

	// Start is the start time for the query (default one hour ago)
	// Supports Datemath
	Start string `json:"start,omitempty"`
}

StreamRequest represents parameters for Loki streaming queries via tail endpoint.

+kubebuilder:object:generate=true

func (*StreamRequest) DeepCopy

func (in *StreamRequest) DeepCopy() *StreamRequest

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StreamRequest.

func (*StreamRequest) DeepCopyInto

func (in *StreamRequest) DeepCopyInto(out *StreamRequest)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*StreamRequest) GetStart

func (r *StreamRequest) GetStart() (time.Time, error)

GetStart parses the start time using datemath

func (*StreamRequest) Params

func (r *StreamRequest) Params() url.Values

Params returns the URL query parameters for the Loki streaming request

type StreamResponse

type StreamResponse struct {
	Streams        []Result       `json:"streams"`
	DroppedEntries []DroppedEntry `json:"dropped_entries,omitempty"`
}

StreamResponse represents the response from Loki's tail endpoint

Jump to

Keyboard shortcuts

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