Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultConfig = Config{
HTTPClientTimeout: defaulHTTPClientTimeout,
UserAgent: defaultUserAgent,
}
DefaultConfig represents the default configuration used to construct a client.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { // WriteProto writes the Prom proto WriteRequest to the specified endpoint. WriteProto( ctx context.Context, req *prompb.WriteRequest, opts WriteOptions, ) (WriteResult, WriteError) // WriteTimeSeries converts the []TimeSeries to Protobuf then writes it to the specified endpoint. WriteTimeSeries( ctx context.Context, ts TSList, opts WriteOptions, ) (WriteResult, WriteError) }
Client is used to write timeseries data to a Prom remote write endpoint
type Config ¶
type Config struct { // WriteURL is the URL which the client uses to write to prometheus. WriteURL string `yaml:"writeURL"` //HTTPClientTimeout is the timeout that is set for the client. HTTPClientTimeout time.Duration `yaml:"httpClientTimeout"` // If not nil, http client is used instead of constructing one. HTTPClient *http.Client // UserAgent is the `User-Agent` header in the request. UserAgent string `yaml:"userAgent"` }
Config defines the configuration used to construct a client.
func NewConfig ¶
func NewConfig(opts ...ConfigOption) Config
NewConfig creates a new Config struct based on options passed to the function.
type ConfigOption ¶
type ConfigOption func(*Config)
ConfigOption defines a config option that can be used when constructing a client.
func HTTPClientOption ¶
func HTTPClientOption(httpClient *http.Client) ConfigOption
HTTPClientOption sets the HTTP client that is set for the client.
func HTTPClientTimeoutOption ¶
func HTTPClientTimeoutOption(httpClientTimeout time.Duration) ConfigOption
HTTPClientTimeoutOption sets the timeout that is set for the client.
func UserAgent ¶
func UserAgent(userAgent string) ConfigOption
UserAgent sets the `User-Agent` header in the request.
func WriteURLOption ¶
func WriteURLOption(writeURL string) ConfigOption
WriteURLOption sets the URL which the client uses to write to prometheus.
type TimeSeries ¶
TimeSeries are made of labels and a datapoint.
type WriteError ¶
WriteError is an error that can also return the HTTP status code if the response is what caused an error.
type WriteOptions ¶
type WriteOptions struct { // Headers to append or override the outgoing headers. Headers map[string]string }
WriteOptions specifies additional write options.
type WriteResult ¶
WriteResult returns the successful HTTP status code.