Documentation
¶
Overview ¶
Package promclient is a small read-only client for a Prometheus-compatible query API.
It exists so the hub's notification queries and the worker's sandbox-metrics endpoint share one implementation. Two copies of "parse a Prometheus result vector" would drift, and the second copy is where the subtle bugs live — a value arriving as a string rather than a number, a partial response, an empty vector that means "no data" rather than "zero".
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrNotConfigured ¶
func ErrNotConfigured() error
ErrNotConfigured reports that no endpoint has been set.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client queries a Prometheus-compatible API.
The configuration is swappable at runtime because it arrives on the cluster-config stream: the endpoint and its credential are pushed from the hub rather than baked into a flag, so a rotation reaches every worker without a restart.
func New ¶
New returns a Client. An empty BaseURL leaves it unconfigured, which callers must check with Ready before querying.
func (*Client) QueryRange ¶
func (c *Client) QueryRange(ctx context.Context, promql string, start, end time.Time, step time.Duration) ([]Series, error)
QueryRange runs a range query over [start, end] at the given step.
type Config ¶
type Config struct {
// BaseURL is the query root, e.g. https://obs.example.com/api/query/metrics
// (the /api/v1/... paths are appended to it).
BaseURL string
// Headers are sent with every request; this is where an Authorization
// bearer belongs.
Headers map[string]string
// Timeout bounds a single query. Zero uses a sane default.
Timeout time.Duration
}
Config addresses a Prometheus-compatible query API.