Documentation ¶
Index ¶
- Constants
- func AddTagsToLabels(m *promutils.Labels, tags []string, prefix, tagSeparator string)
- func GetHTTPClient() *http.Client
- func JoinHostPort(host string, port int) string
- func SanitizeLabelName(name string) string
- func SleepCtx(ctx context.Context, sleepDuration time.Duration) bool
- func TestEqualLabelss(t *testing.T, got, want []*promutils.Labels)
- type Client
- func (c *Client) APIServer() string
- func (c *Client) Context() context.Context
- func (c *Client) GetAPIResponse(path string) ([]byte, error)
- func (c *Client) GetAPIResponseWithParamsCtx(ctx context.Context, path string, modifyRequest RequestCallback, ...) ([]byte, error)
- func (c *Client) GetAPIResponseWithReqParams(path string, modifyRequest RequestCallback) ([]byte, error)
- func (c *Client) GetBlockingAPIResponse(path string, inspectResponse ResponseCallback) ([]byte, error)
- func (c *Client) GetBlockingAPIResponseCtx(ctx context.Context, path string, inspectResponse ResponseCallback) ([]byte, error)
- func (c *Client) Stop()
- type ConfigMap
- type HTTPClient
- type RequestCallback
- type ResponseCallback
Constants ¶
const ( // BlockingClientReadTimeout is the maximum duration for waiting the response from GetBlockingAPI* BlockingClientReadTimeout = 10 * time.Minute // DefaultClientReadTimeout is the maximum duration for waiting the response from GetAPI* DefaultClientReadTimeout = time.Minute )
Variables ¶
This section is empty.
Functions ¶
func AddTagsToLabels ¶ added in v1.91.0
AddTagsToLabels adds <prefix>_tags (separated with tagSeparator) to labels and exposes individual tags via <prefix>_tag_* labels, so users could move all the tags into the discovered scrape target with the following relabeling rule in the way similar to kubernetes_sd_configs:
- action: labelmap regex: <prefix>_tag_(.+)
This solves https://stackoverflow.com/questions/44339461/relabeling-in-prometheus
func GetHTTPClient ¶ added in v1.35.1
GetHTTPClient returns default client for http API requests.
func SanitizeLabelName ¶
SanitizeLabelName replaces anything that doesn't match client_label.LabelNameRE with an underscore.
This has been copied from Prometheus sources at util/strutil/strconv.go
Types ¶
type Client ¶ added in v1.35.1
type Client struct {
// contains filtered or unexported fields
}
Client is http client, which talks to the given apiServer passed to NewClient().
func NewClient ¶ added in v1.35.1
func NewClient(apiServer string, ac *promauth.Config, proxyURL *proxy.URL, proxyAC *promauth.Config, httpCfg *promauth.HTTPClientConfig) (*Client, error)
NewClient returns new Client for the given args.
func (*Client) GetAPIResponse ¶ added in v1.35.1
GetAPIResponse returns response for the given absolute path.
func (*Client) GetAPIResponseWithParamsCtx ¶ added in v1.88.0
func (c *Client) GetAPIResponseWithParamsCtx(ctx context.Context, path string, modifyRequest RequestCallback, inspectResponse ResponseCallback) ([]byte, error)
GetAPIResponseWithParamsCtx returns response for given absolute path with blocking client and optional callback for api response,
func (*Client) GetAPIResponseWithReqParams ¶ added in v1.62.0
func (c *Client) GetAPIResponseWithReqParams(path string, modifyRequest RequestCallback) ([]byte, error)
GetAPIResponseWithReqParams returns response for given absolute path with optional callback for request.
func (*Client) GetBlockingAPIResponse ¶ added in v1.49.0
func (c *Client) GetBlockingAPIResponse(path string, inspectResponse ResponseCallback) ([]byte, error)
GetBlockingAPIResponse returns response for given absolute path with blocking client and optional callback for api response,
func (*Client) GetBlockingAPIResponseCtx ¶ added in v1.86.2
func (c *Client) GetBlockingAPIResponseCtx(ctx context.Context, path string, inspectResponse ResponseCallback) ([]byte, error)
GetBlockingAPIResponseCtx returns response for given absolute path with blocking client and optional callback for api response,
type ConfigMap ¶ added in v1.35.1
type ConfigMap struct {
// contains filtered or unexported fields
}
ConfigMap is a map for storing discovery api configs.
It automatically removes old configs which weren't accessed recently.
type HTTPClient ¶ added in v1.86.0
HTTPClient is a wrapper around http.Client with timeouts.
type RequestCallback ¶ added in v1.88.0
RequestCallback is called on the request before sending the request to the server.
type ResponseCallback ¶ added in v1.88.0
ResponseCallback is called on the response before validating and returning the response to the caller.