Documentation ¶
Index ¶
- Constants
- func CreateAndRegisterSDMetrics(reg prometheus.Registerer) (map[string]DiscovererMetrics, error)
- func HTTPClientOptions(opts ...config.HTTPClientOption) func(*Manager)
- func MarshalYAMLWithInlineConfigs(in interface{}) (interface{}, error)
- func Name(n string) func(*Manager)
- func RegisterConfig(config Config)
- func RegisterK8sClientMetricsWithPrometheus(registerer prometheus.Registerer) error
- func RegisterSDMetrics(registerer prometheus.Registerer, rmm RefreshMetricsManager) (map[string]DiscovererMetrics, error)
- func UnmarshalYAMLWithInlineConfigs(out interface{}, unmarshal func(interface{}) error) error
- func Updatert(u time.Duration) func(*Manager)
- type Config
- type Configs
- type Discoverer
- type DiscovererMetrics
- type DiscovererOptions
- type Manager
- func (m *Manager) ApplyConfig(cfg map[string]Configs) error
- func (m *Manager) Providers() []*Provider
- func (m *Manager) Run() error
- func (m *Manager) StartCustomProvider(ctx context.Context, name string, worker Discoverer)
- func (m *Manager) SyncCh() <-chan map[string][]*targetgroup.Group
- func (m *Manager) UnregisterMetrics()
- type MetricRegisterer
- type Metrics
- type NoopDiscovererMetrics
- type Provider
- type RefreshMetrics
- type RefreshMetricsInstantiator
- type RefreshMetricsManager
- type RefreshMetricsVecs
- type StaticConfig
- type StaticProvider
Constants ¶
const (
KubernetesMetricsNamespace = "prometheus_sd_kubernetes"
)
Variables ¶
This section is empty.
Functions ¶
func CreateAndRegisterSDMetrics ¶ added in v0.50.0
func CreateAndRegisterSDMetrics(reg prometheus.Registerer) (map[string]DiscovererMetrics, error)
CreateAndRegisterSDMetrics registers the metrics needed for SD mechanisms. Does not register the metrics for the Discovery Manager. TODO(ptodev): Add ability to unregister the metrics?
func HTTPClientOptions ¶
func HTTPClientOptions(opts ...config.HTTPClientOption) func(*Manager)
HTTPClientOptions sets the list of HTTP client options to expose to Discoverers. It is up to Discoverers to choose to use the options provided.
func MarshalYAMLWithInlineConfigs ¶
func MarshalYAMLWithInlineConfigs(in interface{}) (interface{}, error)
MarshalYAMLWithInlineConfigs helps implement yaml.Marshal for structs that have a Configs field that should be inlined.
func RegisterConfig ¶
func RegisterConfig(config Config)
RegisterConfig registers the given Config type for YAML marshaling and unmarshaling.
func RegisterK8sClientMetricsWithPrometheus ¶ added in v0.50.0
func RegisterK8sClientMetricsWithPrometheus(registerer prometheus.Registerer) error
func RegisterSDMetrics ¶ added in v0.50.0
func RegisterSDMetrics(registerer prometheus.Registerer, rmm RefreshMetricsManager) (map[string]DiscovererMetrics, error)
RegisterSDMetrics registers the metrics used by service discovery mechanisms. RegisterSDMetrics should be called only once during the lifetime of the Prometheus process. There is no need for the Prometheus process to unregister the metrics.
func UnmarshalYAMLWithInlineConfigs ¶
UnmarshalYAMLWithInlineConfigs helps implement yaml.Unmarshal for structs that have a Configs field that should be inlined.
Types ¶
type Config ¶
type Config interface { // Name returns the name of the discovery mechanism. Name() string // NewDiscoverer returns a Discoverer for the Config // with the given DiscovererOptions. NewDiscoverer(DiscovererOptions) (Discoverer, error) // NewDiscovererMetrics returns the metrics used by the service discovery. NewDiscovererMetrics(prometheus.Registerer, RefreshMetricsInstantiator) DiscovererMetrics }
A Config provides the configuration and constructor for a Discoverer.
type Configs ¶
type Configs []Config
Configs is a slice of Config values that uses custom YAML marshaling and unmarshaling to represent itself as a mapping of the Config values grouped by their types.
func (Configs) MarshalYAML ¶
MarshalYAML implements yaml.Marshaler.
func (*Configs) SetDirectory ¶
SetDirectory joins any relative file paths with dir.
func (*Configs) UnmarshalYAML ¶
UnmarshalYAML implements yaml.Unmarshaler.
type Discoverer ¶
type Discoverer interface { // Run hands a channel to the discovery provider (Consul, DNS, etc.) through which // it can send updated target groups. It must return when the context is canceled. // It should not close the update channel on returning. Run(ctx context.Context, up chan<- []*targetgroup.Group) }
Discoverer provides information about target groups. It maintains a set of sources from which TargetGroups can originate. Whenever a discovery provider detects a potential change, it sends the TargetGroup through its channel.
Discoverer does not know if an actual change happened. It does guarantee that it sends the new TargetGroup whenever a change happens.
Discoverers should initially send a full set of all discoverable TargetGroups.
type DiscovererMetrics ¶ added in v0.50.0
type DiscovererMetrics interface { Register() error Unregister() }
DiscovererMetrics are internal metrics of service discovery mechanisms.
type DiscovererOptions ¶
type DiscovererOptions struct { Logger log.Logger Metrics DiscovererMetrics // Extra HTTP client options to expose to Discoverers. This field may be // ignored; Discoverer implementations must opt-in to reading it. HTTPClientOptions []config.HTTPClientOption }
DiscovererOptions provides options for a Discoverer.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager maintains a set of discovery providers and sends each update to a map channel. Targets are grouped by the target set name.
func NewManager ¶
func NewManager(ctx context.Context, logger log.Logger, registerer prometheus.Registerer, sdMetrics map[string]DiscovererMetrics, options ...func(*Manager)) *Manager
NewManager is the Discovery Manager constructor.
func (*Manager) ApplyConfig ¶
ApplyConfig checks if discovery provider with supplied config is already running and keeps them as is. Remaining providers are then stopped and new required providers are started using the provided config.
func (*Manager) Providers ¶ added in v0.37.0
Providers returns the currently configured SD providers.
func (*Manager) StartCustomProvider ¶
func (m *Manager) StartCustomProvider(ctx context.Context, name string, worker Discoverer)
StartCustomProvider is used for sdtool. Only use this if you know what you're doing.
func (*Manager) SyncCh ¶
func (m *Manager) SyncCh() <-chan map[string][]*targetgroup.Group
SyncCh returns a read only channel used by all the clients to receive target updates.
func (*Manager) UnregisterMetrics ¶ added in v0.52.0
func (m *Manager) UnregisterMetrics()
UnregisterMetrics unregisters manager metrics. It does not unregister service discovery or refresh metrics, whose lifecycle is managed independent of the discovery Manager.
type MetricRegisterer ¶ added in v0.50.0
type MetricRegisterer interface { RegisterMetrics() error UnregisterMetrics() }
MetricRegisterer is used by implementations of discovery.Discoverer that need to manage the lifetime of their metrics.
func NewMetricRegisterer ¶ added in v0.50.0
func NewMetricRegisterer(reg prometheus.Registerer, metrics []prometheus.Collector) MetricRegisterer
NewMetricRegisterer creates an instance of a MetricRegisterer. Typically called inside the implementation of the NewDiscoverer() method.
type Metrics ¶ added in v0.50.0
type Metrics struct { FailedConfigs prometheus.Gauge DiscoveredTargets *prometheus.GaugeVec ReceivedUpdates prometheus.Counter DelayedUpdates prometheus.Counter SentUpdates prometheus.Counter }
Metrics to be used with a discovery manager.
func NewManagerMetrics ¶ added in v0.50.0
func NewManagerMetrics(registerer prometheus.Registerer, sdManagerName string) (*Metrics, error)
func (*Metrics) Unregister ¶ added in v0.52.0
func (m *Metrics) Unregister(registerer prometheus.Registerer)
Unregister unregisters all metrics.
type NoopDiscovererMetrics ¶ added in v0.50.0
type NoopDiscovererMetrics struct{}
NoopDiscovererMetrics creates a dummy metrics struct, because this SD doesn't have any metrics.
func (*NoopDiscovererMetrics) Register ¶ added in v0.50.0
func (*NoopDiscovererMetrics) Register() error
Register implements discovery.DiscovererMetrics.
func (*NoopDiscovererMetrics) Unregister ¶ added in v0.50.0
func (*NoopDiscovererMetrics) Unregister()
Unregister implements discovery.DiscovererMetrics.
type Provider ¶ added in v0.37.0
type Provider struct {
// contains filtered or unexported fields
}
Provider holds a Discoverer instance, its configuration, cancel func and its subscribers.
func (*Provider) Discoverer ¶ added in v0.37.0
func (p *Provider) Discoverer() Discoverer
Discoverer return the Discoverer of the provider.
type RefreshMetrics ¶ added in v0.50.0
type RefreshMetrics struct { Failures prometheus.Counter Duration prometheus.Observer }
RefreshMetrics are used by the "refresh" package. We define them here in the "discovery" package in order to avoid a cyclic dependency between "discovery" and "refresh".
type RefreshMetricsInstantiator ¶ added in v0.50.0
type RefreshMetricsInstantiator interface {
Instantiate(mech string) *RefreshMetrics
}
RefreshMetricsInstantiator instantiates the metrics used by the "refresh" package.
type RefreshMetricsManager ¶ added in v0.50.0
type RefreshMetricsManager interface { DiscovererMetrics RefreshMetricsInstantiator }
RefreshMetricsManager is an interface for registering, unregistering, and instantiating metrics for the "refresh" package. Refresh metrics are registered and unregistered outside of the service discovery mechanism. This is so that the same metrics can be reused across different service discovery mechanisms. To manage refresh metrics inside the SD mechanism, we'd need to use const labels which are specific to that SD. However, doing so would also expose too many unused metrics on the Prometheus /metrics endpoint.
func NewRefreshMetrics ¶ added in v0.50.0
func NewRefreshMetrics(reg prometheus.Registerer) RefreshMetricsManager
type RefreshMetricsVecs ¶ added in v0.50.0
type RefreshMetricsVecs struct {
// contains filtered or unexported fields
}
RefreshMetricsVecs are metric vectors for the "refresh" package. We define them here in the "discovery" package in order to avoid a cyclic dependency between "discovery" and "refresh".
func (*RefreshMetricsVecs) Instantiate ¶ added in v0.50.0
func (m *RefreshMetricsVecs) Instantiate(mech string) *RefreshMetrics
Instantiate returns metrics out of metric vectors.
func (*RefreshMetricsVecs) Register ¶ added in v0.50.0
func (m *RefreshMetricsVecs) Register() error
Register implements discovery.DiscovererMetrics.
func (*RefreshMetricsVecs) Unregister ¶ added in v0.50.0
func (m *RefreshMetricsVecs) Unregister()
Unregister implements discovery.DiscovererMetrics.
type StaticConfig ¶
type StaticConfig []*targetgroup.Group
A StaticConfig is a Config that provides a static list of targets.
func (StaticConfig) Name ¶
func (StaticConfig) Name() string
Name returns the name of the service discovery mechanism.
func (StaticConfig) NewDiscoverer ¶
func (c StaticConfig) NewDiscoverer(DiscovererOptions) (Discoverer, error)
NewDiscoverer returns a Discoverer for the Config.
func (StaticConfig) NewDiscovererMetrics ¶ added in v0.50.0
func (c StaticConfig) NewDiscovererMetrics(prometheus.Registerer, RefreshMetricsInstantiator) DiscovererMetrics
NewDiscovererMetrics returns NoopDiscovererMetrics because no metrics are needed for this service discovery mechanism.
type StaticProvider ¶
type StaticProvider struct {
TargetGroups []*targetgroup.Group
}
StaticProvider holds a list of target groups that never change.
func (*StaticProvider) Run ¶
func (sd *StaticProvider) Run(ctx context.Context, ch chan<- []*targetgroup.Group)
Run implements the Worker interface.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package install has the side-effect of registering all builtin service discovery config types.
|
Package install has the side-effect of registering all builtin service discovery config types. |