promclient

package
v0.0.84 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2023 License: MIT Imports: 33 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterLabelMatchers added in v0.0.77

func FilterLabelMatchers(filter map[string]map[string]struct{}, matcher *labels.Matcher) bool

TODO: better name, this is to check if a matcher is in the filter

func FilterMatchers

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

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

MergeLabelSets merges the labelset b into a

func MergeLabelValues

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

MergeLabelValues merges the labels from b into a

func NormalizePromError

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

func ParserValueToModelValue added in v0.0.83

func ParserValueToModelValue(value parser.Value) (model.Value, error)

ParserValueToModelValue can *parser.Value to model.Value

func RewriteLabels added in v0.0.76

func RewriteLabels(cfgs []*MetricRelabelConfig, labels []string) []string

RewriteLabels simply rewrites the label names passed in if the actions require it

func RewriteMatchers added in v0.0.76

func RewriteMatchers(cfgs []*MetricRelabelConfig, matchers []*labels.Matcher) ([]*labels.Matcher, bool)

RewriteMatchers go through each matcher and replace the label if matches

func StorageWarningsToAPIWarnings added in v0.0.83

func StorageWarningsToAPIWarnings(warnings storage.Warnings) v1.Warnings

StorageWarningsToAPIWarnings simply converts `storage.Warnings` to `v1.Warnings` which is simply converting a []error -> []string TODO: move to a util package?

Types

type API

type API interface {
	// LabelNames returns all the unique label names present in the block in sorted order.
	LabelNames(ctx context.Context, matchers []string, startTime time.Time, endTime time.Time) ([]string, v1.Warnings, error)
	// LabelValues performs a query for the values of the given label.
	LabelValues(ctx context.Context, label string, matchers []string, startTime time.Time, endTime time.Time) (model.LabelValues, v1.Warnings, error)
	// Query performs a query for the given time.
	Query(ctx context.Context, query string, ts time.Time) (model.Value, v1.Warnings, error)
	// QueryRange performs a query for the given range.
	QueryRange(ctx context.Context, query string, r v1.Range) (model.Value, v1.Warnings, error)
	// Series finds series by label matchers.
	Series(ctx context.Context, matches []string, startTime time.Time, endTime time.Time) ([]model.LabelSet, v1.Warnings, 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, v1.Warnings, error)
	// Metadata returns metadata about metrics currently scraped by the metric name.
	Metadata(ctx context.Context, metric, limit string) (map[string][]v1.Metadata, error)
}

API Subset of the interface defined in the prometheus client

func CreateTestServer added in v0.0.76

func CreateTestServer(t *testing.T, path string) (API, func(), error)

CreateTestServer simply will create a test HTTP server on the path defined and return an API client, a clode method, and any error when creating

type APILabels

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

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

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

func (*AbsoluteTimeFilter) GetValue

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

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

func (*AbsoluteTimeFilter) LabelNames added in v0.0.79

func (tf *AbsoluteTimeFilter) LabelNames(ctx context.Context, matchers []string, startTime time.Time, endTime time.Time) ([]string, v1.Warnings, error)

LabelNames returns all the unique label names present in the block in sorted order.

func (*AbsoluteTimeFilter) LabelValues added in v0.0.79

func (tf *AbsoluteTimeFilter) LabelValues(ctx context.Context, label string, matchers []string, startTime time.Time, endTime time.Time) (model.LabelValues, v1.Warnings, error)

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

func (*AbsoluteTimeFilter) Query

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

Query performs a query for the given time.

func (*AbsoluteTimeFilter) QueryRange

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

QueryRange performs a query for the given range.

func (*AbsoluteTimeFilter) Series

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

Series finds series by label matchers.

type AddLabelClient

type AddLabelClient struct {
	API
	Labels model.LabelSet
}

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

func (*AddLabelClient) GetValue

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

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

func (*AddLabelClient) Key

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

Key defines the labelset which identifies this client

func (*AddLabelClient) LabelNames added in v0.0.41

func (c *AddLabelClient) LabelNames(ctx context.Context, matchers []string, startTime time.Time, endTime time.Time) ([]string, v1.Warnings, error)

LabelNames returns all the unique label names present in the block in sorted order.

func (*AddLabelClient) LabelValues

func (c *AddLabelClient) LabelValues(ctx context.Context, label string, matchers []string, startTime time.Time, endTime time.Time) (model.LabelValues, v1.Warnings, error)

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

func (*AddLabelClient) Query

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

Query performs a query for the given time.

func (*AddLabelClient) QueryRange

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

QueryRange performs a query for the given range.

func (*AddLabelClient) Series

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

Series finds series by label matchers.

type ClientArgsWrap added in v0.0.49

type ClientArgsWrap struct {
	api.Client
	// contains filtered or unexported fields
}

ClientArgsWrap wraps the prom API client to add query params to any given urls

func NewClientArgsWrap added in v0.0.49

func NewClientArgsWrap(api api.Client, args map[string]string) *ClientArgsWrap

NewClientArgsWrap returns a client that will add the given args

func (*ClientArgsWrap) URL added in v0.0.49

func (c *ClientArgsWrap) URL(ep string, args map[string]string) *url.URL

URL returns a URL for the given endpoint + args

type DebugAPI

type DebugAPI struct {
	A             API
	PrefixMessage string
}

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

func (*DebugAPI) GetValue

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

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

func (*DebugAPI) LabelNames added in v0.0.44

func (d *DebugAPI) LabelNames(ctx context.Context, matchers []string, startTime time.Time, endTime time.Time) ([]string, v1.Warnings, error)

LabelNames returns all the unique label names present in the block in sorted order.

func (*DebugAPI) LabelValues

func (d *DebugAPI) LabelValues(ctx context.Context, label string, matchers []string, startTime time.Time, endTime time.Time) (model.LabelValues, v1.Warnings, error)

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

func (*DebugAPI) Metadata added in v0.0.76

func (d *DebugAPI) Metadata(ctx context.Context, metric, limit string) (map[string][]v1.Metadata, error)

Metadata returns metadata about metrics currently scraped by the metric name.

func (*DebugAPI) Query

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

Query performs a query for the given time.

func (*DebugAPI) QueryRange

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

QueryRange performs a query for the given range.

func (*DebugAPI) Series

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

Series finds series by label matchers.

type EngineAPI added in v0.0.83

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

EngineAPI implements the API interface using a Queryable and an engine

func NewEngineAPI added in v0.0.83

func NewEngineAPI(e *promql.Engine, q storage.Queryable) (*EngineAPI, error)

NewEngineAPI returns a new EngineAPI

func (*EngineAPI) GetValue added in v0.0.83

func (a *EngineAPI) GetValue(ctx context.Context, start, end time.Time, matchers []*labels.Matcher) (model.Value, v1.Warnings, error)

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

func (*EngineAPI) LabelNames added in v0.0.83

func (a *EngineAPI) LabelNames(ctx context.Context, matchers []string, startTime time.Time, endTime time.Time) ([]string, v1.Warnings, error)

LabelNames returns all the unique label names present in the block in sorted order.

func (*EngineAPI) LabelValues added in v0.0.83

func (a *EngineAPI) LabelValues(ctx context.Context, label string, matchers []string, startTime time.Time, endTime time.Time) (model.LabelValues, v1.Warnings, error)

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

func (*EngineAPI) Metadata added in v0.0.83

func (a *EngineAPI) Metadata(ctx context.Context, metric, limit string) (map[string][]v1.Metadata, error)

Metadata returns metadata about metrics currently scraped by the metric name.

func (*EngineAPI) Query added in v0.0.83

func (a *EngineAPI) Query(ctx context.Context, query string, ts time.Time) (model.Value, v1.Warnings, error)

Query performs a query for the given time.

func (*EngineAPI) QueryRange added in v0.0.83

func (a *EngineAPI) QueryRange(ctx context.Context, query string, r v1.Range) (model.Value, v1.Warnings, error)

QueryRange performs a query for the given range.

func (*EngineAPI) Series added in v0.0.83

func (a *EngineAPI) Series(ctx context.Context, matches []string, startTime time.Time, endTime time.Time) ([]model.LabelSet, v1.Warnings, error)

Series finds series by label matchers.

type ErrorWrap added in v0.0.84

type ErrorWrap struct {
	A   API
	Msg string
}

func (*ErrorWrap) GetValue added in v0.0.84

func (e *ErrorWrap) GetValue(ctx context.Context, start, end time.Time, matchers []*labels.Matcher) (v model.Value, w v1.Warnings, err error)

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

func (*ErrorWrap) LabelNames added in v0.0.84

func (e *ErrorWrap) LabelNames(ctx context.Context, matchers []string, startTime time.Time, endTime time.Time) (v []string, w v1.Warnings, err error)

func (*ErrorWrap) LabelValues added in v0.0.84

func (e *ErrorWrap) LabelValues(ctx context.Context, label string, matchers []string, startTime time.Time, endTime time.Time) (v model.LabelValues, w v1.Warnings, err error)

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

func (*ErrorWrap) Metadata added in v0.0.84

func (e *ErrorWrap) Metadata(ctx context.Context, metric, limit string) (v map[string][]v1.Metadata, err error)

Metadata returns metadata about metrics currently scraped by the metric name.

func (*ErrorWrap) Query added in v0.0.84

func (e *ErrorWrap) Query(ctx context.Context, query string, ts time.Time) (v model.Value, w v1.Warnings, err error)

Query performs a query for the given time.

func (*ErrorWrap) QueryRange added in v0.0.84

func (e *ErrorWrap) QueryRange(ctx context.Context, query string, r v1.Range) (v model.Value, w v1.Warnings, err error)

QueryRange performs a query for the given range.

func (*ErrorWrap) Series added in v0.0.84

func (e *ErrorWrap) Series(ctx context.Context, matches []string, startTime time.Time, endTime time.Time) (v []model.LabelSet, w v1.Warnings, err error)

Series finds series by label matchers.

type FilterLabelVisitor added in v0.0.77

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

FilterLabel implements the parser.Visitor interface to filter selectors based on a labelstet

func NewFilterLabelVisitor added in v0.0.77

func NewFilterLabelVisitor(filter map[string]map[string]struct{}) *FilterLabelVisitor

func (*FilterLabelVisitor) Visit added in v0.0.77

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

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

type FilterMatcherVisitor added in v0.0.77

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

FilterMatcherVisitor implements the parser.Visitor interface to filter matchers based on a labelstet

func NewFilterMatcherVisitor added in v0.0.77

func NewFilterMatcherVisitor(ls model.LabelSet) *FilterMatcherVisitor

func (*FilterMatcherVisitor) Visit added in v0.0.77

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

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

type IgnoreErrorAPI

type IgnoreErrorAPI struct {
	A 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

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

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

func (*IgnoreErrorAPI) Key

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

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

func (*IgnoreErrorAPI) LabelNames added in v0.0.71

func (n *IgnoreErrorAPI) LabelNames(ctx context.Context, matchers []string, startTime time.Time, endTime time.Time) ([]string, v1.Warnings, error)

LabelNames returns all the unique label names present in the block in sorted order.

func (*IgnoreErrorAPI) LabelValues

func (n *IgnoreErrorAPI) LabelValues(ctx context.Context, label string, matchers []string, startTime time.Time, endTime time.Time) (model.LabelValues, v1.Warnings, error)

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

func (*IgnoreErrorAPI) Metadata added in v0.0.76

func (n *IgnoreErrorAPI) Metadata(ctx context.Context, metric, limit string) (map[string][]v1.Metadata, error)

Metadata returns metadata about metrics currently scraped by the metric name.

func (*IgnoreErrorAPI) Query

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

Query performs a query for the given time.

func (*IgnoreErrorAPI) QueryRange

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

QueryRange performs a query for the given range.

func (*IgnoreErrorAPI) Series

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

Series finds series by label matchers.

type LabelFilterClient added in v0.0.77

type LabelFilterClient struct {
	API
	// contains filtered or unexported fields
}

LabelFilterClient filters out calls to the downstream based on a label filter which is pulled and maintained from the downstream API.

func NewLabelFilterClient added in v0.0.77

func NewLabelFilterClient(ctx context.Context, a API, cfg *LabelFilterConfig) (*LabelFilterClient, error)

NewLabelFilterClient returns a LabelFilterClient which will filter the queries sent downstream based on a filter of labels maintained in memory from the downstream API.

func (*LabelFilterClient) GetValue added in v0.0.77

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

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

func (*LabelFilterClient) LabelFilter added in v0.0.77

func (c *LabelFilterClient) LabelFilter() map[string]map[string]struct{}

State returns the current ServerGroupState

func (*LabelFilterClient) Metadata added in v0.0.77

func (c *LabelFilterClient) Metadata(ctx context.Context, metric, limit string) (map[string][]v1.Metadata, error)

Metadata returns metadata about metrics currently scraped by the metric name.

func (*LabelFilterClient) Query added in v0.0.77

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

Query performs a query for the given time.

func (*LabelFilterClient) QueryRange added in v0.0.77

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

Query performs a query for the given time.

func (*LabelFilterClient) Series added in v0.0.77

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

Series finds series by label matchers.

func (*LabelFilterClient) Sync added in v0.0.77

func (c *LabelFilterClient) Sync(ctx context.Context) error

type LabelFilterConfig added in v0.0.77

type LabelFilterConfig struct {
	// DynamicLabels is a list of labels to dynamically maintain a filter from the downstream from
	DynamicLabels []string `yaml:"dynamic_labels"`
	// SyncInterval defines how frequenlty to update the dynamic label filter
	SyncInterval time.Duration `yaml:"sync_interval"`
	// StaticLabelsInclude is a set of labels to always add to the downstream filter
	// this allows you to define some metrics to be included statically if you want to
	// avoid polling the downstream.
	// NOTE: this is not a "secure" measure as this entire label_filter is based on matchers
	// and as such doesn't restrict which metrics they touch (e.g. if you restrict by `__name__`
	// the could just query by another label).
	StaticLabelsInclude map[string][]string `yaml:"static_labels_include"`
	// StaticLabelsExclude is a set of labels to always exclude from the filter. This is done last
	// so it will apply after the dynamic and static lists are added to the filter.
	StaticLabelsExclude map[string][]string `yaml:"static_labels_exclude"`
}

LabelFilterConfig is the configuration for the LabelFilterClient

func (*LabelFilterConfig) UnmarshalYAML added in v0.0.77

func (c *LabelFilterConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

func (*LabelFilterConfig) Validate added in v0.0.77

func (c *LabelFilterConfig) Validate() error

type MetricRelabelConfig added in v0.0.76

type MetricRelabelConfig struct {
	SourceLabel model.LabelName `yaml:"source_label,flow,omitempty"`
	TargetLabel string          `yaml:"target_label,omitempty"`
	// Actions must either (a) not modify the LabelName or (b) be reversible as we need
	// to modify query/matchers appropriately
	// As such we only support:
	// - replace
	// - labeldrop
	// - lowercase
	// - uppercase
	Action relabel.Action `yaml:"action,omitempty"`
}

MetricRelabelConfig defines relabeling to be done *in-client*. This is a significantly constrained version of relabeling (as compared to prometheus ingestion) as these all need to be reversible -- as we need to adjust queries on-the-fly

func (*MetricRelabelConfig) ToRelabelConfig added in v0.0.76

func (c *MetricRelabelConfig) ToRelabelConfig() (*relabel.Config, error)

ToRelabelConfig simply converts our simplified relabel configuration into the equivalent prometheus relabel config. This is a good method to see exactly how these are mapped over.

func (*MetricRelabelConfig) UnmarshalYAML added in v0.0.76

func (c *MetricRelabelConfig) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

func (*MetricRelabelConfig) Validate added in v0.0.76

func (c *MetricRelabelConfig) Validate() error

type MetricsRelabelClient added in v0.0.76

type MetricsRelabelClient struct {
	API
	MetricsRelabelConfigs []*MetricRelabelConfig
	RelabelConfigs        []*relabel.Config
}

MetricsRelabelClient

func NewMetricsRelabelClient added in v0.0.76

func NewMetricsRelabelClient(a API, cfgs []*MetricRelabelConfig) (*MetricsRelabelClient, error)

NewMetricsRelabelClient returns a new MetricsRelabelClient which will intercept and rewrite queries

func (*MetricsRelabelClient) GetValue added in v0.0.76

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

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

func (*MetricsRelabelClient) LabelNames added in v0.0.76

func (c *MetricsRelabelClient) LabelNames(ctx context.Context, matchers []string, startTime time.Time, endTime time.Time) ([]string, v1.Warnings, error)

LabelNames returns all the unique label names present in the block in sorted order.

func (*MetricsRelabelClient) Query added in v0.0.76

Query performs a query for the given time.

func (*MetricsRelabelClient) QueryRange added in v0.0.76

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

QueryRange performs a query for the given range.

func (*MetricsRelabelClient) Series added in v0.0.76

func (c *MetricsRelabelClient) Series(ctx context.Context, matchers []string, startTime time.Time, endTime time.Time) ([]model.LabelSet, v1.Warnings, error)

Series finds series by label matchers.

type MetricsRelabelVisitor added in v0.0.76

type MetricsRelabelVisitor struct {
	MetricsRelabelConfigs []*MetricRelabelConfig
	RelabelConfigs        []*relabel.Config
	// contains filtered or unexported fields
}

MetricsRelabelVisitor implements the parser.Visitor interface to replace the labels

func NewMetricsRelabelVisitor added in v0.0.76

func NewMetricsRelabelVisitor(m []*MetricRelabelConfig, r []*relabel.Config) *MetricsRelabelVisitor

func (*MetricsRelabelVisitor) Visit added in v0.0.76

func (v *MetricsRelabelVisitor) Visit(node parser.Node, path []parser.Node) (w parser.Visitor, err error)

type MultiAPI

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

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

func NewMultiAPI

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

NewMultiAPI returns a MultiAPI

func NewMustMultiAPI added in v0.0.76

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

NewMustMultiAPI returns a MultiAPI

func (*MultiAPI) GetValue

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

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

func (*MultiAPI) LabelNames

func (m *MultiAPI) LabelNames(ctx context.Context, matchers []string, startTime time.Time, endTime time.Time) ([]string, v1.Warnings, error)

LabelNames returns all the unique label names present in the block in sorted order.

func (*MultiAPI) LabelValues

func (m *MultiAPI) LabelValues(ctx context.Context, label string, matchers []string, startTime time.Time, endTime time.Time) (model.LabelValues, v1.Warnings, error)

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

func (*MultiAPI) Metadata added in v0.0.76

func (m *MultiAPI) Metadata(ctx context.Context, metric, limit string) (map[string][]v1.Metadata, error)

Metadata returns metadata about metrics currently scraped by the metric name.

func (*MultiAPI) Query

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

Query performs a query for the given time.

func (*MultiAPI) QueryRange

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

QueryRange performs a query for the given range.

func (*MultiAPI) Series

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

Series finds series by label matchers.

type MultiAPIMetricFunc

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

type PromAPIRemoteRead struct {
	API
	remote.ReadClient
}

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

func (*PromAPIRemoteRead) GetValue

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

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

type PromAPIV1

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

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

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

func (*PromAPIV1) LabelNames added in v0.0.63

func (p *PromAPIV1) LabelNames(ctx context.Context, matchers []string, startTime time.Time, endTime time.Time) ([]string, v1.Warnings, error)

LabelNames returns all the unique label names present in the block in sorted order.

func (*PromAPIV1) LabelValues added in v0.0.63

func (p *PromAPIV1) LabelValues(ctx context.Context, label string, matchers []string, startTime time.Time, endTime time.Time) (model.LabelValues, v1.Warnings, error)

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

func (*PromAPIV1) Query added in v0.0.78

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

Query performs a query for the given time.

func (*PromAPIV1) QueryRange added in v0.0.78

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

QueryRange performs a query for the given range.

func (*PromAPIV1) Series added in v0.0.78

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

Series finds series by label matchers.

type RelativeTimeFilter

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

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

func (*RelativeTimeFilter) GetValue

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

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

func (*RelativeTimeFilter) LabelNames added in v0.0.79

func (tf *RelativeTimeFilter) LabelNames(ctx context.Context, matchers []string, startTime time.Time, endTime time.Time) ([]string, v1.Warnings, error)

LabelNames returns all the unique label names present in the block in sorted order.

func (*RelativeTimeFilter) LabelValues added in v0.0.79

func (tf *RelativeTimeFilter) LabelValues(ctx context.Context, label string, matchers []string, startTime time.Time, endTime time.Time) (model.LabelValues, v1.Warnings, error)

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

func (*RelativeTimeFilter) Query

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

Query performs a query for the given time.

func (*RelativeTimeFilter) QueryRange

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

QueryRange performs a query for the given range.

func (*RelativeTimeFilter) Series

func (tf *RelativeTimeFilter) Series(ctx context.Context, matches []string, startTime time.Time, endTime time.Time) ([]model.LabelSet, v1.Warnings, 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

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

At returns the current timestamp/value pair.

func (*SeriesIterator) Err

func (s *SeriesIterator) Err() error

Err returns the current error.

func (*SeriesIterator) Labels

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

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

func (*SeriesIterator) Next

func (s *SeriesIterator) Next() bool

Next advances the iterator by one.

func (*SeriesIterator) Seek

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

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

type TimeTruncate added in v0.0.49

type TimeTruncate struct {
	API
}

TimeTruncate is a workaround to https://github.com/jacksontj/promxy/issues/212 context: https://github.com/prometheus/prometheus/issues/5972 For now we need to truncate the time so that prometheus doesn't round up and return no data <= the timestamp we requested

func NewTimeTruncate added in v0.0.49

func NewTimeTruncate(a API) *TimeTruncate

NewTimeTruncate returns a new TimeTruncate client -- which will truncate the time to the millisecond.

func (*TimeTruncate) GetValue added in v0.0.49

func (t *TimeTruncate) GetValue(ctx context.Context, start, end time.Time, matchers []*labels.Matcher) (model.Value, v1.Warnings, error)

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

func (*TimeTruncate) Query added in v0.0.49

func (t *TimeTruncate) Query(ctx context.Context, query string, ts time.Time) (model.Value, v1.Warnings, error)

Query performs a query for the given time.

func (*TimeTruncate) QueryRange added in v0.0.49

func (t *TimeTruncate) QueryRange(ctx context.Context, query string, r v1.Range) (model.Value, v1.Warnings, error)

QueryRange performs a query for the given range.

func (*TimeTruncate) Series added in v0.0.49

func (t *TimeTruncate) Series(ctx context.Context, matches []string, startTime time.Time, endTime time.Time) ([]model.LabelSet, v1.Warnings, error)

Series finds series by label matchers.

Jump to

Keyboard shortcuts

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