discovery

package
v1.7.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyTarget = Target{
	// contains filtered or unexported fields
}
View Source
var MaxUpdateFrequency = 5 * time.Second

MaxUpdateFrequency is the minimum time to wait between updating targets. Prometheus uses a static threshold. Do not recommend changing this, except for tests.

Functions

func ComponentTargetsToPromTargetGroups

func ComponentTargetsToPromTargetGroups(jobName string, tgs []Target) map[string][]*targetgroup.Group

func NewFromConvertibleConfig added in v1.2.0

func NewFromConvertibleConfig[T ConvertibleConfig](opts component.Options, conf T) (component.Component, error)

NewFromConvertibleConfig creates a discovery component given a ConvertibleConfig. Convenience function for New.

Types

type Component

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

Component is a reusable component for any discovery implementation. it will handle dynamic updates and exporting targets appropriately for a scrape implementation.

func New

func New(o component.Options, args component.Arguments, creator Creator) (*Component, error)

New creates a discovery component given arguments and a concrete Discovery implementation function.

func (*Component) LiveDebugging added in v1.6.0

func (c *Component) LiveDebugging(_ int)

func (*Component) Run

func (c *Component) Run(ctx context.Context) error

Run implements component.Component.

func (*Component) Update

func (c *Component) Update(args component.Arguments) error

Update implements component.Component.

type ConvertibleConfig added in v1.2.0

type ConvertibleConfig interface {
	// Convert converts the struct into a DiscovererConfig.
	Convert() DiscovererConfig
}

ConvertibleConfig is used to more conveniently convert a configuration struct into a DiscovererConfig.

type Creator

type Creator func(component.Arguments) (DiscovererConfig, error)

Creator is a function provided by an implementation to create a concrete DiscovererConfig instance.

type DiscovererConfig added in v1.2.0

type DiscovererConfig discovery.Config

DiscovererConfig is an alias for Prometheus' DiscovererConfig interface, so users of this package don't need to import github.com/prometheus/prometheus/discover as well.

type DiscovererWithMetrics added in v1.2.0

type DiscovererWithMetrics interface {
	promdiscovery.Discoverer
	promdiscovery.DiscovererMetrics
}

func NewDiscovererWithMetrics added in v1.2.0

func NewDiscovererWithMetrics(cfg promdiscovery.Config, reg prometheus.Registerer, logger log.Logger) (DiscovererWithMetrics, error)

type DistributedTargets

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

DistributedTargets uses the node's Lookup method to distribute discovery targets when a component runs in a cluster.

func NewDistributedTargets

func NewDistributedTargets(clusteringEnabled bool, cluster cluster.Cluster, allTargets []Target) *DistributedTargets

NewDistributedTargets creates the abstraction that allows components to dynamically shard targets between components.

func NewDistributedTargetsWithCustomLabels added in v1.4.2

func NewDistributedTargetsWithCustomLabels(clusteringEnabled bool, cluster cluster.Cluster, allTargets []Target, labels []string) *DistributedTargets

NewDistributedTargetsWithCustomLabels creates the abstraction that allows components to dynamically shard targets between components. Passing in labels will limit the sharding to only use those labels for computing the hash key. Passing in nil or empty array means look at all labels.

func (*DistributedTargets) LocalTargets added in v1.2.0

func (dt *DistributedTargets) LocalTargets() []Target

LocalTargets returns the targets that belong to the local cluster node.

func (*DistributedTargets) MovedToRemoteInstance added in v1.2.0

func (dt *DistributedTargets) MovedToRemoteInstance(prev *DistributedTargets) []Target

MovedToRemoteInstance returns the set of local targets from prev that are no longer local in dt, indicating an active target has moved. Only targets which exist in both prev and dt are returned. If prev contains an empty list of targets, no targets are returned.

func (*DistributedTargets) TargetCount added in v1.4.2

func (dt *DistributedTargets) TargetCount() int

type Exports

type Exports struct {
	Targets []Target `alloy:"targets,attr"`
}

Exports holds values which are exported by all discovery components.

type Target

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

func NewTargetFromLabelSet

func NewTargetFromLabelSet(ls commonlabels.LabelSet) Target

func NewTargetFromMap

func NewTargetFromMap(m map[string]string) Target

func NewTargetFromModelLabels

func NewTargetFromModelLabels(labels modellabels.Labels) Target

NewTargetFromModelLabels creates a target from model Labels. NOTE: this is not optimised and should be avoided on a hot path.

func NewTargetFromSpecificAndBaseLabelSet

func NewTargetFromSpecificAndBaseLabelSet(own, group commonlabels.LabelSet) Target

func (Target) AlloyCapsule

func (t Target) AlloyCapsule()

AlloyCapsule marks FastTarget as a capsule so Alloy syntax can marshal to or from it.

func (Target) AsMap

func (t Target) AsMap() map[string]string

AsMap returns target's labels as a map of strings. Deprecated: this should not be used on any hot path as it leads to more allocation.

func (*Target) ConvertFrom

func (t *Target) ConvertFrom(src interface{}) error

ConvertFrom is called by Alloy syntax to try converting from another type to Target.

func (Target) ConvertInto

func (t Target) ConvertInto(dst interface{}) error

ConvertInto is called by Alloy syntax to try converting Target to another type.

func (Target) Equals

func (t Target) Equals(other any) bool

Equals implements equality.CustomEquality. Works only with pointers.

func (Target) EqualsTarget

func (t Target) EqualsTarget(other *Target) bool

func (Target) ForEachLabel

func (t Target) ForEachLabel(f func(key string, value string) bool) bool

ForEachLabel runs f over each key value pair in the Target. f must not modify Target while iterating. If f returns false, the iteration is interrupted. If f returns true, the iteration continues until the last element. ForEachLabel returns true if all the labels were iterated over or false if any call to f has interrupted the iteration. ForEachLabel does not guarantee iteration order or sort labels in any way.

func (Target) Get

func (t Target) Get(key string) (string, bool)

func (Target) HashLabelsWithPredicate

func (t Target) HashLabelsWithPredicate(pred func(key string) bool) uint64

func (Target) LabelSet

func (t Target) LabelSet() commonlabels.LabelSet

LabelSet converts this target in to a LabelSet Deprecated: this is not optimised and should be avoided if possible.

func (Target) Len

func (t Target) Len() int

func (Target) NonMetaLabelsHash

func (t Target) NonMetaLabelsHash() uint64

func (Target) NonReservedLabelSet

func (t Target) NonReservedLabelSet() commonlabels.LabelSet

func (Target) PromLabels

func (t Target) PromLabels() modellabels.Labels

PromLabels converts this target into prometheus/prometheus/model/labels.Labels. It is not efficient and should be avoided on a hot path.

func (Target) SpecificLabelsHash

func (t Target) SpecificLabelsHash(labelNames []string) uint64

func (Target) String

func (t Target) String() string

type TargetBuilder

type TargetBuilder interface {
	relabel.LabelBuilder
	Target() Target
	MergeWith(Target) TargetBuilder
}

func NewTargetBuilder

func NewTargetBuilder() TargetBuilder

NewTargetBuilder creates an empty labels builder.

func NewTargetBuilderFrom

func NewTargetBuilderFrom(t Target) TargetBuilder

func NewTargetBuilderFromLabelSets

func NewTargetBuilderFromLabelSets(group, own commonlabels.LabelSet) TargetBuilder

Directories

Path Synopsis
Package docker implements the discovery.docker component.
Package docker implements the discovery.docker component.
Package gce implements the discovery.gce component.
Package gce implements the discovery.gce component.
Package kubelet implements a discovery.kubelet component.
Package kubelet implements a discovery.kubelet component.
Package kubernetes implements a discovery.kubernetes component.
Package kubernetes implements a discovery.kubernetes component.

Jump to

Keyboard shortcuts

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