Documentation ¶
Index ¶
- Constants
- func MustRegister(name string, collector prometheus.Collector, opts ...RegisterOption)
- func Register(name string, collector prometheus.Collector, opts ...RegisterOption) error
- type Collector
- type CollectorOption
- type Gatherer
- type GathererOption
- type Group
- type RegisterOption
- type RegisterOptions
- type Registry
- func (r *Registry) Configure(enabled []string, polled []string) (State, error)
- func (r *Registry) Gatherer(opts ...GathererOption) (*Gatherer, error)
- func (r *Registry) NewGatherer(opts ...GathererOption) (*Gatherer, error)
- func (r *Registry) Poll()
- func (r *Registry) Register(name string, collector prometheus.Collector, opts ...RegisterOption) error
- func (r *Registry) State() State
- type State
Constants ¶
const ( // MinPollInterval is the most frequent allowed polling interval. MinPollInterval = 5 * time.Second // DefaultPollInterval is the default interval for polling collectors. DefaultPollInterval = 30 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func MustRegister ¶ added in v0.8.0
func MustRegister(name string, collector prometheus.Collector, opts ...RegisterOption)
MustRegister registers a collector with the default registry, panicking on error.
func Register ¶ added in v0.8.0
func Register(name string, collector prometheus.Collector, opts ...RegisterOption) error
Register registers a collector with the default registry.
Types ¶
type Collector ¶ added in v0.8.0
type Collector struct { State // contains filtered or unexported fields }
Collector is a registered prometheus.Collector.
func NewCollector ¶ added in v0.8.0
func NewCollector(name string, collector prometheus.Collector, options ...CollectorOption) *Collector
NewCollector creates a new collector with the given name and collector.
func (*Collector) Collect ¶ added in v0.8.0
func (c *Collector) Collect(ch chan<- prometheus.Metric)
Collect implements the prometheus.Collector interface.
func (*Collector) Describe ¶ added in v0.8.0
func (c *Collector) Describe(ch chan<- *prometheus.Desc)
Describe implements the prometheus.Collector interface.
func (*Collector) Matches ¶ added in v0.8.0
Matches returns true if the collector matches the given glob pattern.
type CollectorOption ¶ added in v0.8.0
type CollectorOption func(*Collector)
CollectorOption is an option for a Collector.
func WithPolled ¶ added in v0.8.0
func WithPolled() CollectorOption
WithPolled is an option to mark a collector polled.
func WithoutNamespace ¶ added in v0.8.0
func WithoutNamespace() CollectorOption
WithoutNamespace is an option to disable namespace prefixing for a collector.
func WithoutSubsystem ¶ added in v0.8.0
func WithoutSubsystem() CollectorOption
WithoutSubsystem is an option to disable group prefixing for a collector.
type Gatherer ¶ added in v0.8.0
type Gatherer struct { *prometheus.Registry // contains filtered or unexported fields }
Gatherer is a prometheus gatherer for our registry.
func NewGatherer ¶ added in v0.8.0
func NewGatherer(opts ...GathererOption) (*Gatherer, error)
NewGatherer creates a new gatherer for the default registry, with the given options.
func (*Gatherer) Block ¶ added in v0.8.0
func (g *Gatherer) Block()
Block the gatherer from polling collectors.
func (*Gatherer) Gather ¶ added in v0.8.0
func (g *Gatherer) Gather() ([]*model.MetricFamily, error)
Gather implements the prometheus.Gatherer interface.
type GathererOption ¶ added in v0.8.0
type GathererOption func(*Gatherer)
GathererOption is an option for the gatherer.
func WithMetrics ¶ added in v0.8.0
func WithMetrics(enabled, polled []string) GathererOption
WithMetrics defines which groups or collectors will be enabled, and and polled if any.
func WithNamespace ¶ added in v0.8.0
func WithNamespace(namespace string) GathererOption
WithNamespace defines the common namespace prefix for gathered collectors.
func WithPollInterval ¶ added in v0.8.0
func WithPollInterval(interval time.Duration) GathererOption
WithPollInterval defines the polling interval for the gatherer.
func WithoutPolling ¶ added in v0.8.0
func WithoutPolling() GathererOption
WithoutPolling disables internally triggered polling for the gatherer.
type Group ¶ added in v0.8.0
type Group struct {
// contains filtered or unexported fields
}
Group is a collection of collectors.
func (*Group) Collect ¶ added in v0.8.0
func (g *Group) Collect(ch chan<- prometheus.Metric)
Collect implements the prometheus.Collector interface.
func (*Group) Describe ¶ added in v0.8.0
func (g *Group) Describe(ch chan<- *prometheus.Desc)
Describe implements the prometheus.Collector interface.
type RegisterOption ¶ added in v0.8.0
type RegisterOption func(*RegisterOptions)
RegisterOption is an option for registering collectors.
func WithCollectorOptions ¶ added in v0.8.0
func WithCollectorOptions(opts ...CollectorOption) RegisterOption
WithCollectorOptions is an option to register a collector with options.
func WithGroup ¶ added in v0.8.0
func WithGroup(name string) RegisterOption
WithGroup is an option to register a collector in a specific group.
type RegisterOptions ¶ added in v0.8.0
type RegisterOptions struct {
// contains filtered or unexported fields
}
RegisterOptions are options for registering collectors.
type Registry ¶ added in v0.8.0
type Registry struct {
// contains filtered or unexported fields
}
Registry is a collection of groups.
func (*Registry) Configure ¶ added in v0.8.0
Configure enables the collectors matching any of the given globs. Any collector matching any glob in polled is forced to polled mode.
func (*Registry) Gatherer ¶ added in v0.8.0
func (r *Registry) Gatherer(opts ...GathererOption) (*Gatherer, error)
Getherer returns a gatherer for the registry, configured with the given options.
func (*Registry) NewGatherer ¶ added in v0.8.0
func (r *Registry) NewGatherer(opts ...GathererOption) (*Gatherer, error)
NewGatherer creates a new gatherer for the registry, with the given options.
func (*Registry) Poll ¶ added in v0.8.0
func (r *Registry) Poll()
Poll all collectors with are enabled and in polled mode.
func (*Registry) Register ¶ added in v0.8.0
func (r *Registry) Register(name string, collector prometheus.Collector, opts ...RegisterOption) error
Register registers a collector with the registry.
type State ¶ added in v0.8.0
type State int
State represents the configuration of a collector or a group of collectors.
const ( // Enabled marks a collector as enabled. Enabled State = (1 << iota) // Polled marks a collector as polled. Polled collectors return cached metrics // collected during the last polling cycle. This is useful for computationally // expensive metrics that should not be collected during normal collection. Polled // NamespacePrefix causes a collector's metrics to be prefixed with a common // namespace. NamespacePrefix // SubsystemPrefix causes a collecor's metrics to be prefixed with the name // of the group the collector belongs to. SubsystemPrefix // DefaultName is the name of the default group. An alias for "". DefaultName = "default" )
func (State) NeedsNamespace ¶ added in v0.8.0
NeedsNamespace returns true if the collector needs a namespace prefix.
func (State) NeedsSubsystem ¶ added in v0.8.0
NeedsSubsystem returns true if the collector needs a group prefix.