Documentation ¶
Index ¶
- func GetHttpStatusCode(err error) (int, bool)
- func NewClientFromConfig(cfg HTTPClientConfig, name string, disableKeepAlives bool) (*http.Client, error)
- func NewRecoverableError(cause error) error
- func NewTLSConfig(cfg *TLSConfig) (*tls.Config, error)
- func SendBytesWithBackoff(ctx context.Context, client PrometheusClient, req []byte) error
- func SendSamplesWithBackoff(ctx context.Context, client *Client, samples []prompb.TimeSeries, buf *[]byte) error
- type BasicAuth
- type Client
- type ClientConfig
- type HTTPClientConfig
- type HttpError
- type PrometheusClient
- type TLSConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetHttpStatusCode ¶
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 NewTLSConfig ¶
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 ¶
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 ¶
StoreBytes 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 PrometheusClient ¶
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.