prom

package
v0.0.0-...-05b72f9 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHttpStatusCode

func GetHttpStatusCode(err error) (int, bool)

func NewClientFromConfig

func NewClientFromConfig(cfg HTTPClientConfig, name string, disableKeepAlives bool) (*http.Client, error)

NewClientFromConfig returns a new HTTP client configured for the given config.HTTPClientConfig. The name is used as go-conntrack metric label.

func NewRecoverableError

func NewRecoverableError(cause error) error

func NewTLSConfig

func NewTLSConfig(cfg *TLSConfig) (*tls.Config, error)

NewTLSConfig creates a new tls.Config from the given TLSConfig.

func SendBytesWithBackoff

func SendBytesWithBackoff(ctx context.Context, client PrometheusClient, req []byte) error

func SendSamplesWithBackoff

func SendSamplesWithBackoff(ctx context.Context, client *Client, samples []prompb.TimeSeries, buf *[]byte) error

sendSamples to the remote storage with backoff for recoverable errors.

Types

type BasicAuth

type BasicAuth struct {
	Username string `yaml:"username"`
	Password string `yaml:"password,omitempty"`
}

BasicAuth contains basic HTTP authentication credentials.

type Client

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

func NewClient

func NewClient(remoteName string, conf *ClientConfig, retriesCounter counterMetricFunc) (*Client, error)

NewClient creates a new Client.

func (*Client) CountRetries

func (c *Client) CountRetries(retries float64)

CountRetries registers the number of retries the client did internally, in a generic metric. The main purpose is to wrap in a simple way the underlying Prometheus metric.

func (*Client) StoreBytes

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

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

func (*Client) StoreStream

func (c *Client) StoreStream(ctx context.Context, req io.Reader) error

StoreStream 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              *url.URL
	Timeout          time.Duration
	HTTPClientConfig HTTPClientConfig
	UserAgent        string
	Headers          map[string]string
}

ClientConfig configures a Client.

type HTTPClientConfig

type HTTPClientConfig struct {
	// The HTTP basic authentication credentials for the targets.
	BasicAuth *BasicAuth `yaml:"basic_auth,omitempty"`
	// TLSConfig to use to connect to the targets.
	TLSConfig TLSConfig `yaml:"tls_config,omitempty"`
}

HTTPClientConfig configures an HTTP client.

type HttpError

type HttpError struct {
	StatusCode int
	Status     string
	Err        error
}

func (*HttpError) Error

func (e *HttpError) Error() string

func (*HttpError) Unwrap

func (e *HttpError) Unwrap() error

type PrometheusClient

type PrometheusClient interface {
	StoreBytes(ctx context.Context, req []byte) error
	StoreStream(ctx context.Context, req io.Reader) error
	CountRetries(retries float64)
}

type TLSConfig

type TLSConfig struct {
	// The CA cert to use for the targets.
	CAFile string `yaml:"ca_file,omitempty"`
	// The client cert file for the targets.
	CertFile string `yaml:"cert_file,omitempty"`
	// The client key file for the targets.
	KeyFile string `yaml:"key_file,omitempty"`
	// Used to verify the hostname for the targets.
	ServerName string `yaml:"server_name,omitempty"`
	// Disable target certificate validation.
	InsecureSkipVerify bool `yaml:"insecure_skip_verify"`
}

TLSConfig configures the options for TLS connections.

Jump to

Keyboard shortcuts

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