promclient

package
v0.23.2-rc.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2021 License: Apache-2.0 Imports: 33 Imported by: 6

Documentation

Index

Constants

View Source
const (
	SUCCESS = "success"
)

Variables

View Source
var (
	ErrFlagEndpointNotFound = errors.New("no flag endpoint found")
)

Functions

func IsWALDirAccessible added in v0.10.0

func IsWALDirAccessible(dir string) error

IsWALDirAccessible returns no error if WAL dir can be found. This helps to tell if we have access to Prometheus TSDB directory.

Types

type Client added in v0.11.0

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

Client represents a Prometheus API client.

func NewClient added in v0.11.0

func NewClient(c HTTPClient, logger log.Logger, userAgent string) *Client

NewClient returns a new Prometheus API client.

func NewDefaultClient added in v0.14.0

func NewDefaultClient() *Client

NewDefaultClient returns Client with tracing tripperware.

func NewWithTracingClient added in v0.14.0

func NewWithTracingClient(logger log.Logger, userAgent string) *Client

NewWithTracingClient returns client with tracing tripperware.

func (*Client) AlertmanagerAlerts added in v0.14.0

func (c *Client) AlertmanagerAlerts(ctx context.Context, base *url.URL) ([]*model.Alert, error)

AlertmanagerAlerts returns alerts from Alertmanager.

func (*Client) BuildVersion added in v0.21.0

func (c *Client) BuildVersion(ctx context.Context, base *url.URL) (string, error)

BuildVersion returns Prometheus version from /api/v1/status/buildinfo Prometheus endpoint. For Prometheus versions < 2.14.0 it returns "0" as Prometheus version.

func (*Client) ConfiguredFlags added in v0.14.0

func (c *Client) ConfiguredFlags(ctx context.Context, base *url.URL) (Flags, error)

ConfiguredFlags returns configured flags from /api/v1/status/flags Prometheus endpoint. Added to Prometheus from v2.2.

func (*Client) ExemplarsInGRPC added in v0.20.0

func (c *Client) ExemplarsInGRPC(ctx context.Context, base *url.URL, query string, startTime, endTime int64) ([]*exemplarspb.ExemplarData, error)

ExemplarsInGRPC returns the exemplars from Prometheus exemplars API. It uses gRPC errors. NOTE: This method is tested in pkg/store/prometheus_test.go against Prometheus.

func (*Client) ExternalLabels added in v0.14.0

func (c *Client) ExternalLabels(ctx context.Context, base *url.URL) (labels.Labels, error)

ExternalLabels returns sorted external labels from /api/v1/status/config Prometheus endpoint. Note that configuration can be hot reloadable on Prometheus, so this config might change in runtime.

func (*Client) LabelNamesInGRPC added in v0.14.0

func (c *Client) LabelNamesInGRPC(ctx context.Context, base *url.URL, matchers []storepb.LabelMatcher, startTime, endTime int64) ([]string, error)

LabelNames returns all known label names constrained by the given matchers. It uses gRPC errors. NOTE: This method is tested in pkg/store/prometheus_test.go against Prometheus.

func (*Client) LabelValuesInGRPC added in v0.14.0

func (c *Client) LabelValuesInGRPC(ctx context.Context, base *url.URL, label string, matchers []storepb.LabelMatcher, startTime, endTime int64) ([]string, error)

LabelValuesInGRPC returns all known label values for a given label name. It uses gRPC errors. NOTE: This method is tested in pkg/store/prometheus_test.go against Prometheus.

func (*Client) MetricMetadataInGRPC added in v0.19.0

func (c *Client) MetricMetadataInGRPC(ctx context.Context, base *url.URL, metric string, limit int) (map[string][]metadatapb.Meta, error)

MetricMetadataInGRPC returns the metadata from Prometheus metric metadata API. It uses gRPC errors.

func (*Client) PromqlQueryInstant added in v0.11.0

func (c *Client) PromqlQueryInstant(ctx context.Context, base *url.URL, query string, t time.Time, opts QueryOptions) (promql.Vector, []string, error)

PromqlQueryInstant performs instant query and returns results in promql.Vector type that is compatible with promql package.

func (*Client) QueryInstant added in v0.11.0

func (c *Client) QueryInstant(ctx context.Context, base *url.URL, query string, t time.Time, opts QueryOptions) (model.Vector, []string, error)

QueryInstant performs an instant query using a default HTTP client and returns results in model.Vector type.

func (*Client) QueryRange added in v0.15.0

func (c *Client) QueryRange(ctx context.Context, base *url.URL, query string, startTime, endTime, step int64, opts QueryOptions) (model.Matrix, []string, error)

QueryRange performs a range query using a default HTTP client and returns results in model.Matrix type.

func (*Client) RulesInGRPC added in v0.14.0

func (c *Client) RulesInGRPC(ctx context.Context, base *url.URL, typeRules string) ([]*rulespb.RuleGroup, error)

RulesInGRPC returns the rules from Prometheus rules API. It uses gRPC errors. NOTE: This method is tested in pkg/store/prometheus_test.go against Prometheus.

func (*Client) SeriesInGRPC added in v0.14.0

func (c *Client) SeriesInGRPC(ctx context.Context, base *url.URL, matchers []*labels.Matcher, startTime, endTime int64) ([]map[string]string, error)

SeriesInGRPC returns the labels from Prometheus series API. It uses gRPC errors. NOTE: This method is tested in pkg/store/prometheus_test.go against Prometheus.

func (*Client) Snapshot added in v0.14.0

func (c *Client) Snapshot(ctx context.Context, base *url.URL, skipHead bool) (string, error)

Snapshot will request Prometheus to perform snapshot in directory returned by this function. Returned directory is relative to Prometheus data-dir. NOTE: `--web.enable-admin-api` flag has to be set on Prometheus. Added to Prometheus from v2.1. TODO(bwplotka): Add metrics.

func (*Client) TargetsInGRPC added in v0.20.0

func (c *Client) TargetsInGRPC(ctx context.Context, base *url.URL, stateTargets string) (*targetspb.TargetDiscovery, error)

type Flags

type Flags struct {
	TSDBPath           string         `json:"storage.tsdb.path"`
	TSDBRetention      model.Duration `json:"storage.tsdb.retention"`
	TSDBMinTime        model.Duration `json:"storage.tsdb.min-block-duration"`
	TSDBMaxTime        model.Duration `json:"storage.tsdb.max-block-duration"`
	WebEnableAdminAPI  bool           `json:"web.enable-admin-api"`
	WebEnableLifecycle bool           `json:"web.enable-lifecycle"`
}

func (*Flags) UnmarshalJSON

func (f *Flags) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type HTTPClient added in v0.11.0

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

HTTPClient sends an HTTP request and returns the response.

type QueryOptions added in v0.7.0

type QueryOptions struct {
	Deduplicate             bool
	PartialResponseStrategy storepb.PartialResponseStrategy
	Method                  string
}

func (*QueryOptions) AddTo added in v0.7.0

func (p *QueryOptions) AddTo(values url.Values) error

Jump to

Keyboard shortcuts

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