prometheus

package
v0.49.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActiveTarget

type ActiveTarget struct {
	Labels             map[string]string `json:"labels"`
	DiscoveredLabels   map[string]string `json:"discoveredLabels"`
	ScrapePool         string            `json:"scrapePool"`
	ScrapeURL          string            `json:"scrapeUrl"`
	LastError          string            `json:"lastError"`
	LastScrape         time.Time         `json:"lastScrape"`
	LastScrapeDuration float64           `json:"lastScrapeDuration"`
	Health             string            `json:"health"`
}

ActiveTarget represents a Prometheus scrape target

type Alert

type Alert struct {
	Labels      map[string]string `json:"labels"`
	Annotations map[string]string `json:"annotations"`
	State       string            `json:"state"`
	ActiveAt    time.Time         `json:"activeAt"`
	Value       string            `json:"value"`
}

Alert represents a Prometheus alert

type Client

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

Client wraps the Prometheus HTTP API

func NewClient

func NewClient(baseURL string) *Client

NewClient creates a new Prometheus client

func NewProbeClient

func NewProbeClient(baseURL string) *Client

NewProbeClient creates a Prometheus client with a short timeout for connectivity checks

func (*Client) Alerts

func (c *Client) Alerts() ([]Alert, error)

Alerts returns active alerts.

func (*Client) LabelValues

func (c *Client) LabelValues(label string, match []string) ([]string, error)

LabelValues returns all values for a given label name.

func (*Client) Labels

func (c *Client) Labels(match []string) ([]string, error)

Labels returns all label names. Match selectors are optional (e.g. `up{job="foo"}`).

func (*Client) Query

func (c *Client) Query(query string, evalTime time.Time) ([]VectorSample, error)

Query executes an instant PromQL query. evalTime may be zero (defaults to server now).

func (*Client) QueryRange

func (c *Client) QueryRange(query string, start, end time.Time, step time.Duration) ([]MatrixSeries, error)

QueryRange executes a range PromQL query.

func (*Client) Targets

func (c *Client) Targets(state string) ([]ActiveTarget, error)

Targets returns scrape targets. State filter can be "active", "dropped", or "any".

func (*Client) TestConnection

func (c *Client) TestConnection() error

TestConnection verifies the Prometheus instance is ready.

type MatrixSeries

type MatrixSeries struct {
	Metric map[string]string `json:"metric"`
	Values [][2]interface{}  `json:"values"`
}

MatrixSeries is a single range-query result (resultType "matrix")

type VectorSample

type VectorSample struct {
	Metric map[string]string `json:"metric"`
	Value  [2]interface{}    `json:"value"` // [unix_ts, "string_value"]
}

VectorSample is a single instant-query result (resultType "vector")

Jump to

Keyboard shortcuts

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