tenantfederation

package
v0.0.0-...-5028857 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterValuesByMatchers

func FilterValuesByMatchers(idLabelName string, ids []string, matchers ...*labels.Matcher) (matchedIDs map[string]struct{}, unrelatedMatchers []*labels.Matcher)

FilterValuesByMatchers applies matchers to inputed `idLabelName` and `ids`. A set of matched IDs is returned and also all label matchers not targeting the `idLabelName` label.

In case a label matcher is set on a label conflicting with `idLabelName`, we need to rename this labelMatcher's name to its original name. This is used to as part of Select in the mergeQueryable, to ensure only relevant queries are considered and the forwarded matchers do not contain matchers on the `idLabelName`.

func NewExemplarQueryable

func NewExemplarQueryable(upstream storage.ExemplarQueryable, bypassWithSingleQuerier bool, maxConcurrency int, reg prometheus.Registerer, logger log.Logger) storage.ExemplarQueryable

NewExemplarQueryable returns an exemplar queryable that makes requests for all tenant IDs that are part of the request and aggregates the results from each tenant's ExemplarQuerier.

Results contain the series label __tenant_id__ to identify which tenant the exemplar is from.

By setting bypassWithSingleQuerier to true, tenant federation logic gets bypassed if the request is only for a single tenant. The requests will also not contain the pseudo series label __tenant_id__ in this case.

func NewMergeExemplarQueryable

func NewMergeExemplarQueryable(idLabelName string, upstream storage.ExemplarQueryable, bypassWithSingleQuerier bool, maxConcurrency int, reg prometheus.Registerer, logger log.Logger) storage.ExemplarQueryable

NewMergeExemplarQueryable returns an exemplar queryable that makes requests for all tenant IDs that are part of the request and aggregates the results from each tenant's ExemplarQuerier.

Results contain the series label `idLabelName` to identify which tenant the exemplar is from.

By setting bypassWithSingleQuerier to true, tenant federation logic gets bypassed if the request is only for a single tenant. The requests will also not contain the pseudo series label `idLabelName` in this case.

func NewMergeQueryable

func NewMergeQueryable(idLabelName string, callbacks MergeQueryableCallbacks, resolver tenant.Resolver, bypassWithSingleID bool, maxConcurrency int, reg prometheus.Registerer, logger log.Logger) storage.Queryable

NewMergeQueryable returns a queryable that merges results for all involved federation IDs. The underlying querier is returned by a callback in MergeQueryableCallbacks.

By setting bypassWithSingleID to true the mergeQuerier gets bypassed, and results for requests with a single ID will not contain the ID label. This allows for a smoother transition, when enabling tenant federation in a cluster.

Each result contains a label `idLabelName` to identify the federation ID it originally resulted from. If the label `idLabelName` already exists, its value is overwritten and the previous value is exposed through a new label prefixed with "original_". This behaviour is not implemented recursively.

func NewMetadataSupplier

func NewMetadataSupplier(next querier.MetadataSupplier, maxConcurrency int, logger log.Logger) querier.MetadataSupplier

NewMetadataSupplier returns a querier.MetadataSupplier that returns metric metadata for all tenant IDs that are part of the request and merges the results.

No deduplication of metadata is done before being returned.

func NewQueryable

func NewQueryable(upstream storage.Queryable, bypassWithSingleID bool, maxConcurrency int, reg prometheus.Registerer, logger log.Logger) storage.Queryable

NewQueryable returns a queryable that iterates through all the tenant IDs that are part of the request and aggregates the query results for tenant. By setting bypassWithSingleID to true the mergeQuerier gets bypassed and results for requests with a single ID will not contain the "__tenant_id__" label. This allows for a smoother transition, when enabling tenant federation in a cluster. The result contains a label "__tenant_id__" to identify the tenant ID that it originally resulted from. If the label "__tenant_id__" already exists, its value is overwritten by the tenant ID and the previous value is exposed through a new label prefixed with "original_". This behaviour is not implemented recursively.

Types

type Config

type Config struct {
	// Enabled switches on support for multi tenant query federation
	Enabled       bool `yaml:"enabled"`
	MaxConcurrent int  `yaml:"max_concurrent" category:"experimental"`
	MaxTenants    int  `yaml:"max_tenants"`
}

func (*Config) RegisterFlags

func (cfg *Config) RegisterFlags(f *flag.FlagSet)

type MergeQuerierUpstream

type MergeQuerierUpstream interface {
	Select(ctx context.Context, id string, sortSeries bool, hints *storage.SelectHints, matchers ...*labels.Matcher) storage.SeriesSet
	LabelValues(ctx context.Context, id string, name string, hints *storage.LabelHints, matchers ...*labels.Matcher) ([]string, annotations.Annotations, error)
	LabelNames(ctx context.Context, id string, hints *storage.LabelHints, matchers ...*labels.Matcher) ([]string, annotations.Annotations, error)
	Close() error
}

MergeQuerierUpstream mirrors storage.Querier, except every query method also takes a federation ID.

type MergeQueryableCallbacks

type MergeQueryableCallbacks struct {
	// Querier returns a MergeQuerierUpstream implementation for mint and maxt.
	Querier func(mint, maxt int64) (MergeQuerierUpstream, error)
}

MergeQueryableCallbacks contains callbacks to NewMergeQueryable, for customizing its behaviour.

Jump to

Keyboard shortcuts

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