Documentation
¶
Overview ¶
Package prometheus builds authenticated clients for the Prometheus HTTP API (Mimir, metrics-query, ...) and normalizes the values they answer with.
Index ¶
- Constants
- func InstantVector(value promModel.Value, at promModel.Time) (promModel.Vector, error)
- func NewApi(endpoint, bearerToken string) (v1.API, error)
- func NewApiWithHeaders(endpoint string, headers map[string]string) (v1.API, error)
- func NewTenantApi(endpoint, tenant string) (v1.API, error)
- type BearerTransport
- type HeaderTransport
Constants ¶
const TenantHeader = "X-Scope-OrgID"
TenantHeader is the header Mimir reads the tenant from.
Variables ¶
This section is empty.
Functions ¶
func InstantVector ¶
InstantVector reduces whatever an instant query answered with to the vector the caller asked for. The prometheus API contract says an instant query returns a vector, but the query path in front of it does not always agree: a matrix comes back for the same query often enough that treating it as unusable meters those orgs at zero, silently, for the hour.
A matrix is the same answer with its history attached, so the sample to take is each series' last one at or before the instant — exactly what the vector would have held.
func NewApi ¶
NewApi returns a Prometheus v1 API client for endpoint that authenticates with bearerToken.
func NewApiWithHeaders ¶
NewApiWithHeaders returns a Prometheus v1 API client for endpoint that sends headers on every request.
func NewTenantApi ¶
NewTenantApi returns a client for a Mimir endpoint that reads from one tenant. It is meant for in-cluster endpoints that do not require authentication (the query-frontend's direct port); a public front door such as metrics-query derives the tenant from the query instead.
Types ¶
type BearerTransport ¶
type BearerTransport struct {
Token string
Next http.RoundTripper
}
BearerTransport adds a bearer token to every request it forwards. An empty token sends the request through untouched.
type HeaderTransport ¶
type HeaderTransport struct {
Headers map[string]string
Next http.RoundTripper
}
HeaderTransport sets fixed headers on every request it forwards.