client

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Code generated by github.com/hasura/ndc-sdk-go/cmd/hasura-ndc-go, DO NOT EDIT.

Index

Constants

View Source
const (
	XScopeOrgID = "X-Scope-OrgID"
)

Variables

This section is empty.

Functions

func FormatUnixNanoTimestamp

func FormatUnixNanoTimestamp(ts time.Time) string

FormatUnixNanoTimestamp formats the time instance to unix timestamp in nanoseconds

Types

type Client

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

Client is a HTTP client to request Loki API resources

func New

func New(cfg ClientSettings) (*Client, error)

New creates a new Loki client

func (*Client) CancelLogDeletionRequest

func (c *Client) CancelLogDeletionRequest(ctx context.Context, requestID string, force *bool) error

CancelLogDeletionRequest cancels a new log deletion request for the authenticated tenant

func (*Client) CreateLogDeletionRequest

func (c *Client) CreateLogDeletionRequest(ctx context.Context, params CreateLogDeletionRequestParams) error

CreateLogDeletionRequest [creates a new log deletion request] for the authenticated tenant

func (*Client) Flush

func (c *Client) Flush(ctx context.Context) error

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

func (*Client) FormatQuery

func (c *Client) FormatQuery(ctx context.Context, query string) (string, error)

FormatQuery formats a LogQL query.

func (*Client) GetLogDeletionRequests

func (c *Client) GetLogDeletionRequests(ctx context.Context) ([]LogDeletionRequest, error)

GetLogDeletionRequests list the existing delete requests for the authenticated tenant

func (*Client) GetRules

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

GetRules returns the loki ruler rules

func (*Client) LabelValues

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

LabelValues retrieve the list of known values for a given label within a given time span.

func (*Client) Labels

func (c *Client) Labels(ctx context.Context, params *LabelsParams) ([]string, error)

Labels retrieve the list of known labels within a given time span

func (*Client) PushLogLines

func (c *Client) PushLogLines(ctx context.Context, params *PushLogLineInput) error

PushLogLines send log entries to Loki.

func (*Client) Query

func (c *Client) Query(ctx context.Context, params *QueryParams) (*QueryData, error)

Query allows for doing queries against a single point in time

func (*Client) QueryRange

func (c *Client) QueryRange(ctx context.Context, params *QueryRangeParams) (*QueryRangeData, error)

QueryRange queries logs within a range of time. This type of query is often referred to as a range query. Range queries are used for both log and metric type LogQL queries

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)

type ClientSettings

type ClientSettings struct {
	// Endpoint of the Loki server.
	URL utils.EnvString `json:"url" yaml:"url"`
	// Headers specify headers to inject in the requests.
	Headers map[string]utils.EnvString `json:"headers" yaml:"headers"`
	// The default timeout in seconds of client requests. The zero value is no timeout.
	Timeout uint `json:"timeout" yaml:"timeout"`
	// The duration to limit the max time range in query requests. If the value is 0 the client will leave the time range validation to Loki server.
	MaxTimeRange model.Duration `json:"max_time_range" yaml:"max_time_range" jsonschema:"type=string,pattern=[0-9]+(h|d|w|y)"`
}

ClientSettings contain information for the Loki server that the client connects to

func (*ClientSettings) UnmarshalJSON

func (cs *ClientSettings) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type CreateLogDeletionRequestParams

type CreateLogDeletionRequestParams struct {
	Query       string           `json:"query"`
	Start       *time.Time       `json:"start,omitempty"`
	End         *time.Time       `json:"end,omitempty"`
	MaxInterval *scalar.Duration `json:"max_interval"`
}

CreateLogDeletionRequestParams input parameters to create a log deletion request

type LabelValuesParams

type LabelValuesParams struct {
	Name string `json:"name"`

	LabelsParams
}

LabelValuesParams represent parameters of the label values request

func (*LabelValuesParams) FromValue

func (j *LabelValuesParams) FromValue(input map[string]any) error

FromValue decodes values from map

type LabelsParams

type LabelsParams struct {
	// The start time for the query as a nanosecond Unix epoch. Defaults to 6 hours ago.
	Start *time.Time `json:"start"`
	// The end time for the query as a nanosecond Unix epoch. Defaults to now.
	End *time.Time `json:"end"`
	// 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 *scalar.Duration `json:"since"`
	// Log stream selector that selects the streams to match and return label names. Example: {app="myapp", environment="dev"}
	Query string `json:"query,omitempty"`
}

LabelsParams represent parameters of the labels request

func (LabelsParams) ApplyQueryParams

func (lp LabelsParams) ApplyQueryParams(q url.Values, maxTimeRange time.Duration) (url.Values, error)

ApplyQueryParams apply values to query parameters

func (*LabelsParams) FromValue

func (j *LabelsParams) FromValue(input map[string]any) error

FromValue decodes values from map

func (LabelsParams) ToMap

func (j LabelsParams) ToMap() map[string]any

ToMap encodes the struct to a value map

type LogDeletionRequest

type LogDeletionRequest struct {
	RequestID string  `json:"request_id"`
	StartTime float64 `json:"start_time"`
	EndTime   float64 `json:"end_time"`
	CreatedAt float64 `json:"created_at"`
	Query     string  `json:"query"`
	Status    string  `json:"status"`
}

LogDeletionRequest the log deletion request item

func (LogDeletionRequest) ToMap

func (j LogDeletionRequest) ToMap() map[string]any

ToMap encodes the struct to a value map

type LogLineInput

type LogLineInput struct {
	Line               string            `json:"line"`
	Timestamp          *time.Time        `json:"timestamp,omitempty"`
	StructuredMetadata map[string]string `json:"structured_metadata,omitempty"`
}

LogLineInput represents a log line item

func (LogLineInput) MarshalJSON

func (lli LogLineInput) MarshalJSON() ([]byte, error)

MarshalJSON marshals the type into valid JSON.

func (LogLineInput) ToMap

func (j LogLineInput) ToMap() map[string]any

ToMap encodes the struct to a value map

type MatrixValue

type MatrixValue struct {
	Time  time.Time         `json:"time"`
	Value model.SampleValue `json:"value"`
}

MatrixValue holds a single timestamp and a metric value

func (MatrixValue) ToMap

func (j MatrixValue) ToMap() map[string]any

ToMap encodes the struct to a value map

type MatrixValues

type MatrixValues struct {
	Metric map[string]string `json:"metric"`
	Values []MatrixValue     `json:"values"`
}

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

func (MatrixValues) ToMap

func (j MatrixValues) ToMap() map[string]any

ToMap encodes the struct to a value map

func (*MatrixValues) UnmarshalJSON

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

UnmarshalJSON implements json.Unmarshaler.

type PushLogLineInput

type PushLogLineInput struct {
	Streams []StreamInput `json:"streams"`
}

PushLogLineInput input arguments of the pushLogLines function.

type QueryData

type QueryData struct {
	ResultType    QueryResultType `json:"resultType"`
	Vector        []VectorValue   `json:"vector,omitempty"`
	EncodingFlags []string        `json:"encodingFlags,omitempty"`
}

QueryData holds the result type and a metric vector value of the instant query response

func (QueryData) ToMap

func (j QueryData) ToMap() map[string]any

ToMap encodes the struct to a value map

func (*QueryData) UnmarshalJSON

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

UnmarshalJSON implements json.Unmarshaler.

type QueryDirection

type QueryDirection string

QueryDirection determines the sort order of logs @enum forward,backward

const (
	QueryDirectionForward  QueryDirection = "forward"
	QueryDirectionBackward QueryDirection = "backward"
)

func ParseQueryDirection

func ParseQueryDirection(input string) (QueryDirection, error)

ParseQueryDirection parses a QueryDirection enum from string

func (*QueryDirection) FromValue

func (s *QueryDirection) FromValue(value any) error

FromValue decodes the scalar from an unknown value

func (QueryDirection) IsValid

func (j QueryDirection) IsValid() bool

IsValid checks if the value is invalid

func (QueryDirection) ScalarName

func (j QueryDirection) ScalarName() string

ScalarName get the schema name of the scalar

func (*QueryDirection) UnmarshalJSON

func (j *QueryDirection) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

type QueryParams

type QueryParams struct {
	// The LogQL query to perform.
	Query string `json:"query"`
	// The max number of entries to return. It defaults to 100. Only applies to query types which produce a stream (log lines) response.
	Limit int `json:"limit,omitempty"`
	// The evaluation time for the query as a nanosecond Unix epoch or RFC3339 format. Defaults to now.
	Time *time.Time `json:"time"`
	// Determines the sort order of logs. Supported values are forward or backward. Defaults to backward.
	Direction *QueryDirection `json:"direction"`
}

QueryParams request parameters for the query function

func (*QueryParams) FromValue

func (j *QueryParams) FromValue(input map[string]any) error

FromValue decodes values from map

type QueryRangeData

type QueryRangeData struct {
	ResultType    QueryResultType `json:"resultType"`
	Stream        []StreamValues  `json:"stream,omitempty"`
	Matrix        []MatrixValues  `json:"matrix,omitempty"`
	EncodingFlags []string        `json:"encodingFlags,omitempty"`
}

QueryRangeData holds the result type and a list of stream or metric values of the query range response

func (QueryRangeData) ToMap

func (j QueryRangeData) ToMap() map[string]any

ToMap encodes the struct to a value map

func (*QueryRangeData) UnmarshalJSON

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

UnmarshalJSON implements json.Unmarshaler.

type QueryRangeParams

type QueryRangeParams struct {
	// The LogQL query to perform.
	Query string `json:"query"`
	// The max number of entries to return. It defaults to 100. Only applies to query types which produce a stream (log lines) response.
	Limit int `json:"limit,omitempty"`
	// The start time for the query as a nanosecond Unix epoch or RFC3339 format. Defaults to one hour ago.
	// Loki returns results with timestamp greater or equal to this value.
	Start *time.Time `json:"start"`
	// The end time for the query as a nanosecond Unix epoch or RFC3339 format.
	// Defaults to now. Loki returns results with timestamp lower than this value.
	End *time.Time `json:"end"`
	// 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 *scalar.Duration `json:"since"`
	// Query resolution step width in duration format or float number of seconds.
	// Only applies to query types which produce a matrix response.
	Step *scalar.Duration `json:"step"`
	// Only return entries at (or greater than) the specified interval, can be a duration format or float number of seconds.
	// Only applies to queries which produce a stream response.
	Interval *scalar.Duration `json:"interval"`
	// Determines the sort order of logs. Supported values are forward or backward. Defaults to backward.
	Direction *QueryDirection `json:"direction"`
}

QueryRangeParams request parameters for the query range function

func (*QueryRangeParams) FromValue

func (j *QueryRangeParams) FromValue(input map[string]any) error

FromValue decodes values from map

type QueryResultType

type QueryResultType string

QueryResultType represents the enum of query result types

const (
	ResultTypeVector  QueryResultType = "vector"
	ResultTypeStreams QueryResultType = "streams"
	ResultTypeMatrix  QueryResultType = "matrix"
)

type Rules

type Rules struct {
	Name  string        `json:"name"`
	File  string        `json:"file"`
	Rules []interface{} `json:"rules"`
}

Rules the rule item

type RulesData

type RulesData struct {
	Groups []Rules `json:"groups"`
}

RulesData the data of rules

type RulesResponse

type RulesResponse struct {
	Status string    `json:"status"`
	Data   RulesData `json:"data"`
}

RulesResponse the response data of Loki rules

type StreamInput

type StreamInput struct {
	Stream map[string]string `json:"stream,omitempty"`
	Values []LogLineInput    `json:"values"`
}

StreamInput represents a stream input object.

func (StreamInput) ToMap

func (j StreamInput) ToMap() map[string]any

ToMap encodes the struct to a value map

type StreamValue

type StreamValue struct {
	Time  time.Time `json:"time"`
	Value string    `json:"value"`
}

StreamValue holds a timestamp and the content of a log line.

func (StreamValue) ToMap

func (j StreamValue) ToMap() map[string]any

ToMap encodes the struct to a value map

type StreamValues

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

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

func (StreamValues) ToMap

func (j StreamValues) ToMap() map[string]any

ToMap encodes the struct to a value map

func (*StreamValues) UnmarshalJSON

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

UnmarshalJSON implements json.Unmarshaler.

type VectorValue

type VectorValue struct {
	Metric map[string]string `json:"metric"`
	Time   time.Time         `json:"time"`
	Value  model.SampleValue `json:"value"`
}

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

func (VectorValue) ToMap

func (j VectorValue) ToMap() map[string]any

ToMap encodes the struct to a value map

func (*VectorValue) UnmarshalJSON

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

UnmarshalJSON implements json.Unmarshaler.

Jump to

Keyboard shortcuts

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