utils

package
v0.0.0-...-6ee8545 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// Read defines the type of client. It is used to fetch the auth from authStore.
	Read = iota
	// Write defines the type of client. It is used to fetch the auth from authStore.
	Write
)
View Source
const (
	LabelJob = "job"
	Megabyte = 1024 * 1024
)

Variables

This section is empty.

Functions

func CreatePrombQuery

func CreatePrombQuery(mint, maxt int64, matchers []*labels.Matcher) (*prompb.Query, error)

CreatePrombQuery creates a new promb query based on the matchers.

func HashLabels

func HashLabels(lset prompb.Labels) uint64

HashLabels returns the hash of the provided promb labels-set. It fetches the value of the hash from the labelsCache if exists, else creates the hash and returns it after storing the new hash value.

func LabelSet

func LabelSet(metricName, migrationJobName string) []prompb.Label

LabelSet creates a new label_set for the provided metric name and job name.

func ParseClientInfo

func ParseClientInfo(conf *ClientConfig) error

Types

type Auth

type Auth struct {
	Username        string
	Password        string
	PasswordFile    string
	BearerToken     string
	BearerTokenFile string
	config.TLSConfig
}

Auth defines the authentication for prom-migrator.

func (*Auth) ToHTTPClientConfig

func (a *Auth) ToHTTPClientConfig() config.HTTPClientConfig

Convert converts the auth credentials to HTTP client compatible format.

type Client

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

func NewClient

func NewClient(remoteName string, clientConfig ClientConfig, httpConfig promConfig.HTTPClientConfig) (*Client, error)

NewClient creates a new read or write client. The `clientType` should be either `read` or `write`. The client type is used to get the auth from the auth store. If the `clientType` is other than the ones specified, then auth may not work.

func (*Client) Config

func (c *Client) Config() ClientConfig

Config returns the client runtime.

func (*Client) Read

func (c *Client) Read(ctx context.Context, query *prompb.Query, desc string) (result *prompb.QueryResult, numBytesCompressed int, numBytesUncompressed int, err error)

func (*Client) ReadConcurrent

func (c *Client) ReadConcurrent(ctx context.Context, query *prompb.Query, shardID int, desc string, responseChan chan<- interface{})

ReadConcurrent calls the Read and responds on the channels.

func (*Client) Store

func (c *Client) Store(ctx context.Context, req []byte) error

Store sends a batch of samples to the HTTP endpoint, the request is the proto marshalled and encoded bytes from codec.go.

type ClientConfig

type ClientConfig struct {
	URL          string
	Timeout      time.Duration
	OnTimeout    RecoveryAction
	OnTimeoutStr string
	OnErr        RecoveryAction
	OnErrStr     string
	MaxRetry     int
	// Delay defines the time we should wait before a retry. This can happen
	// either in a timeout or after an error.
	Delay         time.Duration
	CustomHeaders map[string][]string
}

type HeadersFlag

type HeadersFlag struct {
	Headers map[string][]string
}

func (HeadersFlag) Set

func (f HeadersFlag) Set(value string) error

func (HeadersFlag) String

func (f HeadersFlag) String() string

type PrompbResponse

type PrompbResponse struct {
	ID                   int
	Result               *prompb.QueryResult
	NumBytesCompressed   int
	NumBytesUncompressed int
}

PrompbResponse is a type that contains promb-result and information pertaining to it.

type RecoverableError

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

RecoverableError is an error for which the send samples can retry with a backoff.

type RecoveryAction

type RecoveryAction uint8
const (
	// Retry makes the client to retry in case of a timeout or error.
	Retry RecoveryAction = iota
	// Skip makes the client to skip the current slab.
	Skip
	// Abort aborts the client from any further retries and exits the migration process.
	// This can be applied after a timeout or error.
	Abort
)

func RecoveryActionEnum

func RecoveryActionEnum(typ string) (RecoveryAction, error)

Jump to

Keyboard shortcuts

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