Documentation ¶
Index ¶
Constants ¶
const (
// DefaultRemoteWrite is the default Prom remote write endpoint in m3coordinator.
DefaultRemoteWrite = "http://localhost:7201/api/v1/prom/remote/write"
)
Variables ¶
var DefaultConfig = Config{ WriteURL: DefaultRemoteWrite, 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 such as the one in m3coordinator.
type Config ¶
type Config struct { // WriteURL is the URL which the client uses to write to m3coordinator. 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 m3coordinator.
type TimeSeries ¶
TimeSeries are made of labels and a datapoint.
type WriteError ¶ added in v0.2.0
WriteError is an error that can also return the HTTP status code if the response is what caused an error.
type WriteOptions ¶ added in v0.4.0
type WriteOptions struct { // Headers to append or override the outgoing headers. Headers map[string]string }
WriteOptions specifies additional write options.
type WriteResult ¶ added in v0.2.0
type WriteResult struct {
StatusCode int
}
WriteResult returns the successful HTTP status code.