promclient

package
v0.0.39 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterMatchers added in v0.0.33

func FilterMatchers(ls model.LabelSet, matchers []*labels.Matcher) ([]*labels.Matcher, bool)

FilterMatchers applies the matchers to the given labelset to determine if there is a match and to return all remaining matchers to be matched

func MergeLabelSets added in v0.0.31

func MergeLabelSets(a, b []model.LabelSet) []model.LabelSet

MergeLabelSets merges the labelset b into a

func MergeLabelValues added in v0.0.18

func MergeLabelValues(a, b []model.LabelValue) []model.LabelValue

MergeLabelValues merges the labels from b into a

func NormalizePromError added in v0.0.31

func NormalizePromError(err error) error

NormalizePromError converts the errors that the prometheus API client returns into errors that the prometheus API server actually handles and returns proper error codes for

Types

type API added in v0.0.31

type API interface {
	// LabelValues performs a query for the values of the given label.
	LabelValues(ctx context.Context, label string) (model.LabelValues, error)
	// Query performs a query for the given time.
	Query(ctx context.Context, query string, ts time.Time) (model.Value, error)
	// QueryRange performs a query for the given range.
	QueryRange(ctx context.Context, query string, r v1.Range) (model.Value, error)
	// Series finds series by label matchers.
	Series(ctx context.Context, matches []string, startTime time.Time, endTime time.Time) ([]model.LabelSet, error)
	// GetValue loads the raw data for a given set of matchers in the time range
	GetValue(ctx context.Context, start, end time.Time, matchers []*labels.Matcher) (model.Value, error)
}

API Subset of the interface defined in the prometheus client

type APILabels added in v0.0.34

type APILabels interface {
	API
	// Key returns a labelset used to determine other api clients that are the "same"
	Key() model.LabelSet
}

APILabels includes a Key() mechanism to differentiate which APIs are "the same"

type AbsoluteTimeFilter added in v0.0.39

type AbsoluteTimeFilter struct {
	API
	Start, End time.Time
}

AbsoluteTimeFilter will filter queries out (return nil,nil) for all queries outside the given times

func (*AbsoluteTimeFilter) GetValue added in v0.0.39

func (tf *AbsoluteTimeFilter) GetValue(ctx context.Context, start, end time.Time, matchers []*labels.Matcher) (model.Value, error)

GetValue loads the raw data for a given set of matchers in the time range

func (*AbsoluteTimeFilter) Query added in v0.0.39

func (tf *AbsoluteTimeFilter) Query(ctx context.Context, query string, ts time.Time) (model.Value, error)

Query performs a query for the given time.

func (*AbsoluteTimeFilter) QueryRange added in v0.0.39

func (tf *AbsoluteTimeFilter) QueryRange(ctx context.Context, query string, r v1.Range) (model.Value, error)

QueryRange performs a query for the given range.

func (*AbsoluteTimeFilter) Series added in v0.0.39

func (tf *AbsoluteTimeFilter) Series(ctx context.Context, matches []string, startTime time.Time, endTime time.Time) ([]model.LabelSet, error)

Series finds series by label matchers.

type AddLabelClient added in v0.0.33

type AddLabelClient struct {
	API
	Labels model.LabelSet
}

AddLabelClient proxies a client and adds the given labels to all results

func (*AddLabelClient) GetValue added in v0.0.33

func (c *AddLabelClient) GetValue(ctx context.Context, start, end time.Time, matchers []*labels.Matcher) (model.Value, error)

GetValue loads the raw data for a given set of matchers in the time range

func (*AddLabelClient) Key added in v0.0.34

func (c *AddLabelClient) Key() model.LabelSet

Key defines the labelset which identifies this client

func (*AddLabelClient) LabelValues added in v0.0.33

func (c *AddLabelClient) LabelValues(ctx context.Context, label string) (model.LabelValues, error)

LabelValues performs a query for the values of the given label.

func (*AddLabelClient) Query added in v0.0.33

func (c *AddLabelClient) Query(ctx context.Context, query string, ts time.Time) (model.Value, error)

Query performs a query for the given time.

func (*AddLabelClient) QueryRange added in v0.0.33

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

QueryRange performs a query for the given range.

func (*AddLabelClient) Series added in v0.0.33

func (c *AddLabelClient) Series(ctx context.Context, matches []string, startTime time.Time, endTime time.Time) ([]model.LabelSet, error)

Series finds series by label matchers.

type DebugAPI added in v0.0.39

type DebugAPI struct {
	API
	PrefixMessage string
}

DebugAPI simply logs debug lines for the given API with the given prefix

func (*DebugAPI) GetValue added in v0.0.39

func (d *DebugAPI) GetValue(ctx context.Context, start, end time.Time, matchers []*labels.Matcher) (model.Value, error)

GetValue loads the raw data for a given set of matchers in the time range

func (*DebugAPI) LabelValues added in v0.0.39

func (d *DebugAPI) LabelValues(ctx context.Context, label string) (model.LabelValues, error)

LabelValues performs a query for the values of the given label.

func (*DebugAPI) Query added in v0.0.39

func (d *DebugAPI) Query(ctx context.Context, query string, ts time.Time) (model.Value, error)

Query performs a query for the given time.

func (*DebugAPI) QueryRange added in v0.0.39

func (d *DebugAPI) QueryRange(ctx context.Context, query string, r v1.Range) (model.Value, error)

QueryRange performs a query for the given range.

func (*DebugAPI) Series added in v0.0.39

func (d *DebugAPI) Series(ctx context.Context, matches []string, startTime time.Time, endTime time.Time) ([]model.LabelSet, error)

Series finds series by label matchers.

type IgnoreErrorAPI added in v0.0.34

type IgnoreErrorAPI struct {
	API
}

IgnoreErrorAPI simply swallows all errors from the given API. This allows the API to be used with all the regular error merging logic and effectively have its errors not considered

func (*IgnoreErrorAPI) GetValue added in v0.0.34

func (n *IgnoreErrorAPI) GetValue(ctx context.Context, start, end time.Time, matchers []*labels.Matcher) (model.Value, error)

GetValue loads the raw data for a given set of matchers in the time range

func (*IgnoreErrorAPI) Key added in v0.0.34

func (n *IgnoreErrorAPI) Key() model.LabelSet

Key returns a labelset used to determine other api clients that are the "same"

func (*IgnoreErrorAPI) LabelValues added in v0.0.34

func (n *IgnoreErrorAPI) LabelValues(ctx context.Context, label string) (model.LabelValues, error)

LabelValues performs a query for the values of the given label.

func (*IgnoreErrorAPI) Query added in v0.0.34

func (n *IgnoreErrorAPI) Query(ctx context.Context, query string, ts time.Time) (model.Value, error)

Query performs a query for the given time.

func (*IgnoreErrorAPI) QueryRange added in v0.0.34

func (n *IgnoreErrorAPI) QueryRange(ctx context.Context, query string, r v1.Range) (model.Value, error)

QueryRange performs a query for the given range.

func (*IgnoreErrorAPI) Series added in v0.0.34

func (n *IgnoreErrorAPI) Series(ctx context.Context, matches []string, startTime time.Time, endTime time.Time) ([]model.LabelSet, error)

Series finds series by label matchers.

type LabelFilterVisitor added in v0.0.33

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

LabelFilterVisitor implements the promql.Visitor interface to filter selectors based on a labelstet

func (*LabelFilterVisitor) Visit added in v0.0.33

func (l *LabelFilterVisitor) Visit(node promql.Node, path []promql.Node) (w promql.Visitor, err error)

Visit checks if the given node matches the labels in the filter

type MultiAPI added in v0.0.31

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

MultiAPI implements the API interface while merging the results from the apis it wraps

func NewMultiAPI added in v0.0.31

func NewMultiAPI(apis []API, antiAffinity model.Time, metricFunc MultiAPIMetricFunc, requiredCount int) *MultiAPI

NewMultiAPI returns a MultiAPI

func (*MultiAPI) GetValue added in v0.0.32

func (m *MultiAPI) GetValue(ctx context.Context, start, end time.Time, matchers []*labels.Matcher) (model.Value, error)

GetValue fetches a `model.Value` which represents the actual collected data

func (*MultiAPI) LabelValues added in v0.0.31

func (m *MultiAPI) LabelValues(ctx context.Context, label string) (model.LabelValues, error)

LabelValues performs a query for the values of the given label.

func (*MultiAPI) Query added in v0.0.31

func (m *MultiAPI) Query(ctx context.Context, query string, ts time.Time) (model.Value, error)

Query performs a query for the given time.

func (*MultiAPI) QueryRange added in v0.0.31

func (m *MultiAPI) QueryRange(ctx context.Context, query string, r v1.Range) (model.Value, error)

QueryRange performs a query for the given range.

func (*MultiAPI) Series added in v0.0.31

func (m *MultiAPI) Series(ctx context.Context, matches []string, startTime time.Time, endTime time.Time) ([]model.LabelSet, error)

Series finds series by label matchers.

type MultiAPIMetricFunc added in v0.0.31

type MultiAPIMetricFunc func(i int, api, status string, took float64)

MultiAPIMetricFunc defines a method where a client can record metrics about the specific API calls made through this multi client

type PromAPIRemoteRead added in v0.0.32

type PromAPIRemoteRead struct {
	API
	*remote.Client
}

PromAPIRemoteRead implements our internal API interface using a combination of the v1 HTTP API and the "experimental" remote_read API

func (*PromAPIRemoteRead) GetValue added in v0.0.32

func (p *PromAPIRemoteRead) GetValue(ctx context.Context, start, end time.Time, matchers []*labels.Matcher) (model.Value, error)

GetValue loads the raw data for a given set of matchers in the time range

type PromAPIV1 added in v0.0.32

type PromAPIV1 struct {
	v1.API
}

PromAPIV1 implements our internal API interface using *only* the v1 HTTP API Simply wraps the prom API to fullfil our internal API interface

func (*PromAPIV1) GetValue added in v0.0.32

func (p *PromAPIV1) GetValue(ctx context.Context, start, end time.Time, matchers []*labels.Matcher) (model.Value, error)

GetValue loads the raw data for a given set of matchers in the time range

func (*PromAPIV1) LabelValues added in v0.0.38

func (p *PromAPIV1) LabelValues(ctx context.Context, label string) (model.LabelValues, error)

LabelValues performs a query for the values of the given label.

func (*PromAPIV1) Query added in v0.0.38

func (p *PromAPIV1) Query(ctx context.Context, query string, ts time.Time) (model.Value, error)

Query performs a query for the given time.

func (*PromAPIV1) QueryRange added in v0.0.38

func (p *PromAPIV1) QueryRange(ctx context.Context, query string, r v1.Range) (model.Value, error)

QueryRange performs a query for the given range.

func (*PromAPIV1) Series added in v0.0.38

func (p *PromAPIV1) Series(ctx context.Context, matches []string, startTime time.Time, endTime time.Time) ([]model.LabelSet, error)

Series finds series by label matchers.

type RelativeTimeFilter added in v0.0.39

type RelativeTimeFilter struct {
	API
	Start, End *time.Duration
}

RelativeTimeFilter will filter queries out (return nil,nil) for all queries outside the given durations relative to time.Now()

func (*RelativeTimeFilter) GetValue added in v0.0.39

func (tf *RelativeTimeFilter) GetValue(ctx context.Context, start, end time.Time, matchers []*labels.Matcher) (model.Value, error)

GetValue loads the raw data for a given set of matchers in the time range

func (*RelativeTimeFilter) Query added in v0.0.39

func (tf *RelativeTimeFilter) Query(ctx context.Context, query string, ts time.Time) (model.Value, error)

Query performs a query for the given time.

func (*RelativeTimeFilter) QueryRange added in v0.0.39

func (tf *RelativeTimeFilter) QueryRange(ctx context.Context, query string, r v1.Range) (model.Value, error)

QueryRange performs a query for the given range.

func (*RelativeTimeFilter) Series added in v0.0.39

func (tf *RelativeTimeFilter) Series(ctx context.Context, matches []string, startTime time.Time, endTime time.Time) ([]model.LabelSet, error)

Series finds series by label matchers.

type SeriesIterator

type SeriesIterator struct {
	V interface{}
	// contains filtered or unexported fields
}

SeriesIterator implements the prometheus SeriesIterator interface

func IteratorsForValue

func IteratorsForValue(v model.Value) []*SeriesIterator

IteratorsForValue returns SeriesIterators for the value passed in

func NewSeriesIterator

func NewSeriesIterator(v interface{}) *SeriesIterator

NewSeriesIterator return a series iterator for the given value TODO: error return if the type is incorrect?

func (*SeriesIterator) At added in v0.0.2

func (s *SeriesIterator) At() (t int64, v float64)

At returns the current timestamp/value pair.

func (*SeriesIterator) Err added in v0.0.2

func (s *SeriesIterator) Err() error

Err returns the current error.

func (*SeriesIterator) Labels added in v0.0.2

func (s *SeriesIterator) Labels() labels.Labels

Labels returns the labels of the series that the iterator corresponds to.

func (*SeriesIterator) Next added in v0.0.2

func (s *SeriesIterator) Next() bool

Next advances the iterator by one.

func (*SeriesIterator) Seek added in v0.0.2

func (s *SeriesIterator) Seek(t int64) bool

Seek advances the iterator forward to the value at or after the given timestamp.

Jump to

Keyboard shortcuts

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