Help us shape the future of Go! Take the 2026 Go Developer Survey

client

package
v3.7.8 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatTS added in v3.1.0

func FormatTS(ts time.Time) string

Types

type Client

type Client struct {
	Now time.Time
	// contains filtered or unexported fields
}

Client is a HTTP client that adds basic auth and scope

func New

func New(instanceID, token, baseURL string, opts ...Option) *Client

NewLogsClient creates a new client

func (*Client) AddDeleteRequest

func (c *Client) AddDeleteRequest(params DeleteRequestParams) error

AddDeleteRequest adds a new delete request

func (*Client) Flush

func (c *Client) Flush() error

Flush all in-memory chunks held by the ingesters to the backing store

func (*Client) Get

func (c *Client) Get(path string) (*http.Response, error)

func (*Client) GetDeleteRequests

func (c *Client) GetDeleteRequests() (DeleteRequests, error)

GetDeleteRequests returns all delete requests

func (*Client) GetRules

func (c *Client) GetRules(ctx context.Context) (*RulesResponse, error)

GetRules returns the loki ruler rules

func (*Client) LabelNames

func (c *Client) LabelNames(ctx context.Context) ([]string, error)

func (*Client) LabelValues

func (c *Client) LabelValues(ctx context.Context, labelName string) ([]string, error)

LabelValues return a LabelValues query result

func (*Client) Metrics

func (c *Client) Metrics() (string, error)

Get all the metrics

func (*Client) PushLogLine

func (c *Client) PushLogLine(line string, timestamp time.Time, structuredMetadata map[string]string, extraLabelList ...map[string]string) error

func (*Client) PushOTLPLogLine

func (c *Client) PushOTLPLogLine(line string, timestamp time.Time, logAttributes map[string]any) error

func (*Client) RunQuery

func (c *Client) RunQuery(ctx context.Context, query string, extraHeaders ...Header) (*Response, error)

RunQuery runs a query and returns an error if anything went wrong

func (*Client) RunRangeQuery

func (c *Client) RunRangeQuery(ctx context.Context, query string, extraHeaders ...Header) (*Response, error)

RunRangeQuery runs a 7d query and returns an error if anything went wrong This function is kept to keep backwards copatibility of existing tests. Better use (*Client).RunRangeQueryWithStartEnd()

func (*Client) RunRangeQueryWithStartEnd

func (c *Client) RunRangeQueryWithStartEnd(ctx context.Context, query string, start, end time.Time, extraHeaders ...Header) (*Response, error)

RunRangeQuery runs a query and returns an error if anything went wrong

func (*Client) Series

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

Series return a series query result

func (*Client) Stats

func (c *Client) Stats(ctx context.Context, query string) ([]map[string]int, error)

func (*Client) Tail

func (c *Client) Tail(ctx context.Context, query string, out chan TailResult) (*websocket.Conn, error)

type DataType

type DataType struct {
	ResultType    string
	Stream        []StreamValues
	Matrix        []MatrixValues
	Vector        []VectorValues
	EncodingFlags []string
}

DataType holds the result type and a list of StreamValues

func (*DataType) UnmarshalJSON

func (a *DataType) UnmarshalJSON(b []byte) error

type DeleteRequest

type DeleteRequest struct {
	StartTime int64  `json:"start_time"`
	EndTime   int64  `json:"end_time"`
	Query     string `json:"query"`
	Status    string `json:"status"`
}

type DeleteRequestParams

type DeleteRequestParams struct {
	Query string `json:"query"`
	Start string `json:"start,omitempty"`
	End   string `json:"end,omitempty"`
}

type DeleteRequests

type DeleteRequests []DeleteRequest

type Entry

type Entry []string

func (*Entry) UnmarshalJSON

func (e *Entry) UnmarshalJSON(data []byte) error
type Header struct {
	Name, Value string
}

type InjectHeadersOption

type InjectHeadersOption map[string][]string

func (InjectHeadersOption) Type

func (n InjectHeadersOption) Type() string

type MatrixValues

type MatrixValues struct {
	Metric map[string]string
	Values [][]interface{}
}

MatrixValues holds a label key value pairs for the metric and a list of a list of values

type Option

type Option interface {
	Type() string
}

type Response

type Response struct {
	Status string
	Data   DataType
}

Response holds the status and data

type Rules

type Rules struct {
	Name  string
	File  string
	Rules []interface{}
}

type RulesData

type RulesData struct {
	Groups []Rules
}

type RulesResponse

type RulesResponse struct {
	Status string
	Data   RulesData
}

type StreamValues

type StreamValues struct {
	Stream map[string]string
	Values []Entry
}

StreamValues holds a label key value pairs for the Stream and a list of a list of values

type TailResult

type TailResult struct {
	Response loghttp.TailResponse
	Err      error
}

type VectorValues

type VectorValues struct {
	Metric map[string]string `json:"metric"`
	Time   time.Time
	Value  string
}

VectorValues holds a label key value pairs for the metric and single timestamp and value

func (*VectorValues) UnmarshalJSON

func (a *VectorValues) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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