Documentation ¶
Overview ¶
Package mutable handles mutable labels.
Index ¶
- func MergeRegex(input []string) (string, error)
- func NewIndexWrapper(index types.Index, labelProcessor *LabelProcessor, logger zerolog.Logger) types.Index
- type Label
- type LabelKey
- type LabelProcessor
- func (lp *LabelProcessor) AddMutableLabels(ctx context.Context, lbls labels.Labels) (labels.Labels, error)
- func (lp *LabelProcessor) IsMutableLabel(ctx context.Context, tenant, name string) (bool, error)
- func (lp *LabelProcessor) MutableLabelNames(ctx context.Context, tenant string) ([]string, error)
- func (lp *LabelProcessor) ReplaceMutableLabels(ctx context.Context, matchers []*labels.Matcher) ([]*labels.Matcher, error)
- type LabelProvider
- type LabelWithName
- type LabelWithValues
- type NonMutableLabels
- type Options
- type Provider
- func (cp *Provider) AllValues(ctx context.Context, tenant, name string) ([]string, error)
- func (cp *Provider) DeleteLabelNames(ctx context.Context, labelKeys []LabelKey) error
- func (cp *Provider) DeleteLabelValues(ctx context.Context, lbls []Label) error
- func (cp *Provider) Dump(ctx context.Context, w io.Writer) error
- func (cp *Provider) GetMutable(ctx context.Context, tenant, name, value string) (labels.Labels, error)
- func (cp *Provider) GetNonMutable(ctx context.Context, tenant, name, value string) (NonMutableLabels, error)
- func (cp *Provider) Import(ctx context.Context, r io.Reader, w io.Writer, dryRun bool) error
- func (cp *Provider) MutableLabelNames(ctx context.Context, tenant string) ([]string, error)
- func (cp *Provider) WriteLabelNames(ctx context.Context, lbls []LabelWithName) error
- func (cp *Provider) WriteLabelValues(ctx context.Context, lbls []LabelWithValues) error
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MergeRegex ¶
MergeRegex returns a regular expression matching any of the input strings.
func NewIndexWrapper ¶
func NewIndexWrapper( index types.Index, labelProcessor *LabelProcessor, logger zerolog.Logger, ) types.Index
NewIndexWrapper returns an index wrapper that handles mutable labels.
Types ¶
type Label ¶
type Label struct { Tenant string `json:"tenant"` Name string `json:"name"` Value string `json:"value"` }
Label represents a mutable label with its value.
type LabelProcessor ¶
type LabelProcessor struct {
// contains filtered or unexported fields
}
LabelProcessor can replace mutable labels by non mutable labels.
func NewLabelProcessor ¶
func NewLabelProcessor(provider LabelProvider, tenantLabelName string) *LabelProcessor
func (*LabelProcessor) AddMutableLabels ¶
func (lp *LabelProcessor) AddMutableLabels(ctx context.Context, lbls labels.Labels) (labels.Labels, error)
AddMutableLabels searches for non mutable labels and add their corresponding mutable labels if they exist. For example if we have a mutable label group "mygroup" which contains 'server1', and the label instance="server1" as input, the label group="mygroup" will be added. It also removes any mutable labels present in the input.
func (*LabelProcessor) IsMutableLabel ¶
IsMutableLabel returns whether the label name is mutable.
func (*LabelProcessor) MutableLabelNames ¶
MutableLabelNames returns all the mutable label names possible for a tenant.
func (*LabelProcessor) ReplaceMutableLabels ¶
func (lp *LabelProcessor) ReplaceMutableLabels( ctx context.Context, matchers []*labels.Matcher, ) ([]*labels.Matcher, error)
ReplaceMutableLabels searches for mutable labels and replace them by non mutable labels. For example if we have a mutable label group "mygroup" which contains 'server1' and 'server2', the label matcher group="mygroup" becomes instance="server1|server2".
type LabelProvider ¶
type LabelProvider interface { GetMutable(ctx context.Context, tenant, name, value string) (labels.Labels, error) GetNonMutable(ctx context.Context, tenant, name, value string) (NonMutableLabels, error) AllValues(ctx context.Context, tenant, name string) ([]string, error) MutableLabelNames(ctx context.Context, tenant string) ([]string, error) }
LabelProvider allows to get non mutable labels from a mutable label.
type LabelWithName ¶
type LabelWithName struct { Tenant string `json:"tenant"` Name string `json:"name"` AssociatedName string `json:"associated_name"` }
LabelWithName represents a mutable label name with its associated non mutable label name.
type LabelWithValues ¶
type LabelWithValues struct { Tenant string `json:"tenant"` Name string `json:"name"` Value string `json:"value"` AssociatedValues []string `json:"associated_values"` }
LabelWithValues represents a mutable label with its associated non mutable labels value.
type NonMutableLabels ¶
NonMutableLabels represents a list of labels with a single name.
type Options ¶
type Options struct { Connection *connection.Connection ReadOnly bool Logger zerolog.Logger }
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider allows to get mutable labels.
func NewProvider ¶
func NewProvider( ctx context.Context, reg prometheus.Registerer, cluster types.Cluster, store Store, logger zerolog.Logger, ) *Provider
NewProvider returns a new mutable label provider.
func (*Provider) AllValues ¶
AllValues returns all possible mutable label values for a tenant and a label name.
func (*Provider) DeleteLabelNames ¶
DeleteLabelNames deletes mutable label names in the store.
func (*Provider) DeleteLabelValues ¶
DeleteLabelValues deletes label values in the store.
func (*Provider) GetMutable ¶
func (cp *Provider) GetMutable(ctx context.Context, tenant, name, value string) (labels.Labels, error)
GetMutable returns the mutable labels corresponding to a non mutable label name and value.
func (*Provider) GetNonMutable ¶
func (cp *Provider) GetNonMutable(ctx context.Context, tenant, name, value string) (NonMutableLabels, error)
GetNonMutable returns the non mutable labels corresponding to a mutable label name and value.
func (*Provider) Import ¶
Import read a CSV with all mutable labels to known. Existing labels are dropped then import is done. In output, show some information about import.
func (*Provider) MutableLabelNames ¶
MutableLabelNames returns all the mutable label names possible for a tenant.
func (*Provider) WriteLabelNames ¶
func (cp *Provider) WriteLabelNames(ctx context.Context, lbls []LabelWithName) error
WriteLabelNames writes the label names to the store.
func (*Provider) WriteLabelValues ¶
func (cp *Provider) WriteLabelValues(ctx context.Context, lbls []LabelWithValues) error
WriteLabelValues writes the label values to the store.
type Store ¶
type Store interface { AssociatedNames(ctx context.Context, tenant string) (map[string]string, error) AssociatedValues(ctx context.Context, tenant, name string) (map[string][]string, error) DeleteAssociatedName(ctx context.Context, tenant, name string) error DeleteAssociatedValues(ctx context.Context, label Label) error SetAssociatedName(ctx context.Context, label LabelWithName) error SetAssociatedValues(ctx context.Context, label LabelWithValues) error AllMutableLabels(ctx context.Context) ([]LabelWithName, error) }