prom

package
v0.0.0-...-5861b17 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlertFilter

type AlertFilter struct {
	// Labels filters alerts by attached labels. If only a key is provided, we only match on the key.
	// Values that start with "regexp/" are regexp compiled and then matched against a value stored at that key.
	// Defaults to all labels.
	Labels map[string]string

	// ActiveAt filters out any alerts that are before this time. Defaults to all alerts.
	ActiveAt time.Time
	// States filters alerts to only ones in these states. Defaults to all states.
	States []string

	// Value filters out all values that don't match the regex.
	Value *regexp.Regexp
	// contains filtered or unexported fields
}

AlertFilter represents a filter you can use to filter out alerts.

func (*AlertFilter) Compile

func (a *AlertFilter) Compile() error

Compile compiles the AlertFilter. If this is a one off query, no need to do this. If you plan to reuse the filter, this will increase the speed. Changing a filter after Compile() is called will not give you the desired result, create a new filter instead.

type Client

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

Client is a wrapper around the prometheus Go client for our needs.

func New

func New(httpAddr string) (*Client, error)

New creates a new client connecting to the HTTP address provided. This should be in the form of http[s]://[domain,host,ip]:[port] .

func (*Client) Alerts

func (c *Client) Alerts(ctx context.Context, filter AlertFilter) (chan v1.Alert, error)

Alerts will return all the alerts that match the filter.

func (*Client) Metric

func (c *Client) Metric(ctx context.Context, metric string) (model.Value, v1.Warnings, error)

Metric returns the metrics current value.

func (*Client) Range

func (c *Client) Range(ctx context.Context, query string, r v1.Range) (model.Value, v1.Warnings, error)

Range does a query within a range of time and returns the result. A query might be something like: "rate(prometheus_tsdb_head_samples_appended_total[5m])".

Jump to

Keyboard shortcuts

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