prometheus

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package prometheus implements providers.MetricsProvider against the Prometheus HTTP API — also spoken by VictoriaMetrics — for instant and range PromQL queries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client queries a Prometheus-compatible metrics backend.

func New

func New(baseURL string) *Client

New builds a client for a Prometheus/VictoriaMetrics base URL, unauthenticated.

func NewWithAuth added in v0.3.0

func NewWithAuth(baseURL, tokenEnv string, headers map[string]string) *Client

NewWithAuth builds a client that adds optional auth to every request. tokenEnv names an env var holding a bearer token (empty, or pointing at an unset/empty var, ⇒ no Authorization header); headers are static request headers (e.g. "X-Scope-OrgID" for a multi-tenant backend). The token is read from the environment at request-build time and is never logged.

func (*Client) Query

func (c *Client) Query(ctx context.Context, promql string, at time.Time) (providers.Samples, error)

Query runs an instant PromQL query (at = zero means "now").

func (*Client) QueryRange

func (c *Client) QueryRange(ctx context.Context, promql string, w providers.TimeWindow, step time.Duration) (providers.Matrix, error)

QueryRange runs a range PromQL query over a window.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL