Documentation ¶
Index ¶
- func FilterMatchers(ls model.LabelSet, matchers []*labels.Matcher) ([]*labels.Matcher, bool)
- func MergeLabelSets(a, b []model.LabelSet) []model.LabelSet
- func MergeLabelValues(a, b []model.LabelValue) []model.LabelValue
- func NormalizePromError(err error) error
- func RewriteLabels(cfgs []*MetricRelabelConfig, labels []string) []string
- func RewriteMatchers(cfgs []*MetricRelabelConfig, matchers []*labels.Matcher) ([]*labels.Matcher, bool)
- type API
- type APILabels
- type AbsoluteTimeFilter
- func (tf *AbsoluteTimeFilter) GetValue(ctx context.Context, start, end time.Time, matchers []*labels.Matcher) (model.Value, v1.Warnings, error)
- func (tf *AbsoluteTimeFilter) Query(ctx context.Context, query string, ts time.Time) (model.Value, v1.Warnings, error)
- func (tf *AbsoluteTimeFilter) QueryRange(ctx context.Context, query string, r v1.Range) (model.Value, v1.Warnings, error)
- func (tf *AbsoluteTimeFilter) Series(ctx context.Context, matches []string, startTime time.Time, endTime time.Time) ([]model.LabelSet, v1.Warnings, error)
- type AddLabelClient
- func (c *AddLabelClient) GetValue(ctx context.Context, start, end time.Time, matchers []*labels.Matcher) (model.Value, v1.Warnings, error)
- func (c *AddLabelClient) Key() model.LabelSet
- func (c *AddLabelClient) LabelNames(ctx context.Context, matchers []string, startTime time.Time, endTime time.Time) ([]string, v1.Warnings, error)
- func (c *AddLabelClient) LabelValues(ctx context.Context, label string, matchers []string, startTime time.Time, ...) (model.LabelValues, v1.Warnings, error)
- func (c *AddLabelClient) Query(ctx context.Context, query string, ts time.Time) (model.Value, v1.Warnings, error)
- func (c *AddLabelClient) QueryRange(ctx context.Context, query string, r v1.Range) (model.Value, v1.Warnings, error)
- func (c *AddLabelClient) Series(ctx context.Context, matches []string, startTime time.Time, endTime time.Time) ([]model.LabelSet, v1.Warnings, error)
- type ClientArgsWrap
- type DebugAPI
- func (d *DebugAPI) GetValue(ctx context.Context, start, end time.Time, matchers []*labels.Matcher) (model.Value, v1.Warnings, error)
- func (d *DebugAPI) LabelNames(ctx context.Context, matchers []string, startTime time.Time, endTime time.Time) ([]string, v1.Warnings, error)
- func (d *DebugAPI) LabelValues(ctx context.Context, label string, matchers []string, startTime time.Time, ...) (model.LabelValues, v1.Warnings, error)
- func (d *DebugAPI) Metadata(ctx context.Context, metric, limit string) (map[string][]v1.Metadata, error)
- func (d *DebugAPI) Query(ctx context.Context, query string, ts time.Time) (model.Value, v1.Warnings, error)
- func (d *DebugAPI) QueryRange(ctx context.Context, query string, r v1.Range) (model.Value, v1.Warnings, error)
- func (d *DebugAPI) Series(ctx context.Context, matches []string, startTime time.Time, endTime time.Time) ([]model.LabelSet, v1.Warnings, error)
- type IgnoreErrorAPI
- func (n *IgnoreErrorAPI) GetValue(ctx context.Context, start, end time.Time, matchers []*labels.Matcher) (model.Value, v1.Warnings, error)
- func (n *IgnoreErrorAPI) Key() model.LabelSet
- func (n *IgnoreErrorAPI) LabelNames(ctx context.Context, matchers []string, startTime time.Time, endTime time.Time) ([]string, v1.Warnings, error)
- func (n *IgnoreErrorAPI) LabelValues(ctx context.Context, label string, matchers []string, startTime time.Time, ...) (model.LabelValues, v1.Warnings, error)
- func (n *IgnoreErrorAPI) Metadata(ctx context.Context, metric, limit string) (map[string][]v1.Metadata, error)
- func (n *IgnoreErrorAPI) Query(ctx context.Context, query string, ts time.Time) (model.Value, v1.Warnings, error)
- func (n *IgnoreErrorAPI) QueryRange(ctx context.Context, query string, r v1.Range) (model.Value, v1.Warnings, error)
- func (n *IgnoreErrorAPI) Series(ctx context.Context, matches []string, startTime time.Time, endTime time.Time) ([]model.LabelSet, v1.Warnings, error)
- type LabelFilterVisitor
- type MetricRelabelConfig
- type MetricsRelabelClient
- func (c *MetricsRelabelClient) GetValue(ctx context.Context, start, end time.Time, matchers []*labels.Matcher) (model.Value, v1.Warnings, error)
- func (c *MetricsRelabelClient) LabelNames(ctx context.Context, matchers []string, startTime time.Time, endTime time.Time) ([]string, v1.Warnings, error)
- func (c *MetricsRelabelClient) Query(ctx context.Context, query string, ts time.Time) (model.Value, v1.Warnings, error)
- func (c *MetricsRelabelClient) QueryRange(ctx context.Context, query string, r v1.Range) (model.Value, v1.Warnings, error)
- func (c *MetricsRelabelClient) Series(ctx context.Context, matchers []string, startTime time.Time, endTime time.Time) ([]model.LabelSet, v1.Warnings, error)
- type MetricsRelabelVisitor
- type MultiAPI
- func (m *MultiAPI) GetValue(ctx context.Context, start, end time.Time, matchers []*labels.Matcher) (model.Value, v1.Warnings, error)
- func (m *MultiAPI) LabelNames(ctx context.Context, matchers []string, startTime time.Time, endTime time.Time) ([]string, v1.Warnings, error)
- func (m *MultiAPI) LabelValues(ctx context.Context, label string, matchers []string, startTime time.Time, ...) (model.LabelValues, v1.Warnings, error)
- func (m *MultiAPI) Metadata(ctx context.Context, metric, limit string) (map[string][]v1.Metadata, error)
- func (m *MultiAPI) Query(ctx context.Context, query string, ts time.Time) (model.Value, v1.Warnings, error)
- func (m *MultiAPI) QueryRange(ctx context.Context, query string, r v1.Range) (model.Value, v1.Warnings, error)
- func (m *MultiAPI) Series(ctx context.Context, matches []string, startTime time.Time, endTime time.Time) ([]model.LabelSet, v1.Warnings, error)
- type MultiAPIMetricFunc
- type PromAPIRemoteRead
- type PromAPIV1
- func (p *PromAPIV1) GetValue(ctx context.Context, start, end time.Time, matchers []*labels.Matcher) (model.Value, v1.Warnings, error)
- func (p *PromAPIV1) LabelNames(ctx context.Context, matchers []string, startTime time.Time, endTime time.Time) ([]string, v1.Warnings, error)
- func (p *PromAPIV1) LabelValues(ctx context.Context, label string, matchers []string, startTime time.Time, ...) (model.LabelValues, v1.Warnings, error)
- type RelativeTimeFilter
- func (tf *RelativeTimeFilter) GetValue(ctx context.Context, start, end time.Time, matchers []*labels.Matcher) (model.Value, v1.Warnings, error)
- func (tf *RelativeTimeFilter) Query(ctx context.Context, query string, ts time.Time) (model.Value, v1.Warnings, error)
- func (tf *RelativeTimeFilter) QueryRange(ctx context.Context, query string, r v1.Range) (model.Value, v1.Warnings, error)
- func (tf *RelativeTimeFilter) Series(ctx context.Context, matches []string, startTime time.Time, endTime time.Time) ([]model.LabelSet, v1.Warnings, error)
- type SeriesIterator
- type TimeTruncate
- func (t *TimeTruncate) GetValue(ctx context.Context, start, end time.Time, matchers []*labels.Matcher) (model.Value, v1.Warnings, error)
- func (t *TimeTruncate) Query(ctx context.Context, query string, ts time.Time) (model.Value, v1.Warnings, error)
- func (t *TimeTruncate) QueryRange(ctx context.Context, query string, r v1.Range) (model.Value, v1.Warnings, error)
- func (t *TimeTruncate) Series(ctx context.Context, matches []string, startTime time.Time, endTime time.Time) ([]model.LabelSet, v1.Warnings, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilterMatchers ¶
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 ¶
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 ¶
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 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
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
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 ¶
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) 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.
type AddLabelClient ¶
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.
type ClientArgsWrap ¶ added in v0.0.49
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
type DebugAPI ¶
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.
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.
type LabelFilterVisitor ¶
type LabelFilterVisitor struct {
// contains filtered or unexported fields
}
LabelFilterVisitor implements the parser.Visitor interface to filter selectors based on a labelstet
func NewLabelFilterVisitor ¶ added in v0.0.72
func NewLabelFilterVisitor(ls model.LabelSet) *LabelFilterVisitor
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
func (c *MetricsRelabelClient) Query(ctx context.Context, query string, ts time.Time) (model.Value, v1.Warnings, error)
Query performs a query for the given time.
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
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) (*MultiAPI, error)
NewMultiAPI returns a MultiAPI
func NewMustMultiAPI ¶ added in v0.0.76
func NewMustMultiAPI(apis []API, antiAffinity model.Time, metricFunc MultiAPIMetricFunc, requiredCount int) *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.
type MultiAPIMetricFunc ¶
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
type PromAPIV1 ¶
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
type RelativeTimeFilter ¶
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) 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.
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) 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
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.