promclient

package
v0.0.0-...-4b46047 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

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 wraps the Prometheus API client

func NewClient

func NewClient(prometheusURL string, httpClient *http.Client) (*Client, error)

NewClient creates a new Prometheus client with the given URL and HTTP client. httpClient is required so callers cannot silently inherit client_golang's default transport (which has no SSRF dial/redirect policy).

func (*Client) LabelNames

func (c *Client) LabelNames(ctx context.Context) ([]string, error)

LabelNames returns all label names from Prometheus

func (*Client) LabelValues

func (c *Client) LabelValues(ctx context.Context, label string) ([]string, error)

LabelValues returns all values for a given label name from Prometheus

func (*Client) Query

func (c *Client) Query(ctx context.Context, query string, ts time.Time) (*QueryResult, error)

Query executes an instant query against Prometheus

func (*Client) QueryRange

func (c *Client) QueryRange(ctx context.Context, query string, start, end time.Time, step time.Duration) (*QueryResult, error)

QueryRange executes a range query against Prometheus

type MetricResult

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

MetricResult represents a single metric with its values

type QueryData

type QueryData struct {
	ResultType string         `json:"resultType"`
	Result     []MetricResult `json:"result"`
}

QueryData contains the result type and values

type QueryResult

type QueryResult struct {
	Status string     `json:"status"`
	Data   *QueryData `json:"data,omitempty"`
	Error  string     `json:"error,omitempty"`
}

QueryResult represents the result of a Prometheus query

Jump to

Keyboard shortcuts

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