loki

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

https://github.com/grafana/loki/blob/2dc5a71a6707383aadebe0b10c23c9e09c4f0ce7/integration/client/client.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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)

GetDeleteRequest gets a delete request using the request ID

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

func (*Client) Metrics

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

Get all the metrics

func (*Client) PushLogLine

func (c *Client) PushLogLine(line string, extraLabels ...map[string]string) error

PushLogLine creates a new logline with the current time as timestamp

func (*Client) PushLogLineWithTimestamp

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

PushLogLineWithTimestamp creates a new logline at the given timestamp The timestamp has to be a Unix timestamp (epoch seconds)

func (*Client) RunQuery

func (c *Client) RunQuery(ctx context.Context, query string) (*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) (*Response, error)

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

type DataType

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

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 {
	RequestID string  `json:"request_id"`
	StartTime float64 `json:"start_time"`
	EndTime   float64 `json:"end_time"`
	Query     string  `json:"query"`
	Status    string  `json:"status"`
	CreatedAt float64 `json:"created_at"`
}

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 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 [][]string
}

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

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