metrics

package
v2.4.14 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2021 License: MIT Imports: 25 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// MetricNamePrefix prefix of all metric names.
	MetricNamePrefix = "traefik_"

	// MetricServicePrefix prefix of all service metric names.
	MetricServicePrefix = MetricNamePrefix + "service_"
)

Variables

This section is empty.

Functions

func OnConfigurationUpdate

func OnConfigurationUpdate(conf dynamic.Configuration, entryPoints []string)

OnConfigurationUpdate receives the current configuration from Traefik. It then converts the configuration to the optimized package internal format and sets it to the promState.

func PrometheusHandler

func PrometheusHandler() http.Handler

PrometheusHandler exposes Prometheus routes.

func StopDatadog

func StopDatadog()

StopDatadog stops internal datadogTicker which controls the pushing of metrics to DD Agent and resets it to `nil`.

func StopInfluxDB

func StopInfluxDB()

StopInfluxDB stops internal influxDBTicker which controls the pushing of metrics to InfluxDB Agent and resets it to `nil`.

func StopStatsd

func StopStatsd()

StopStatsd stops internal statsdTicker which controls the pushing of metrics to StatsD Agent and resets it to `nil`.

Types

type HistogramWithScale

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

HistogramWithScale is a histogram that will convert its observed value to the specified unit.

func (*HistogramWithScale) Observe

func (s *HistogramWithScale) Observe(v float64)

Observe implements ScalableHistogram.

func (*HistogramWithScale) ObserveFromStart

func (s *HistogramWithScale) ObserveFromStart(start time.Time)

ObserveFromStart implements ScalableHistogram.

func (*HistogramWithScale) With

func (s *HistogramWithScale) With(labelValues ...string) ScalableHistogram

With implements ScalableHistogram.

type MultiHistogram

type MultiHistogram []ScalableHistogram

MultiHistogram collects multiple individual histograms and treats them as a unit.

func NewMultiHistogram

func NewMultiHistogram(h ...ScalableHistogram) MultiHistogram

NewMultiHistogram returns a multi-histogram, wrapping the passed histograms.

func (MultiHistogram) Observe

func (h MultiHistogram) Observe(v float64)

Observe implements ScalableHistogram.

func (MultiHistogram) ObserveFromStart

func (h MultiHistogram) ObserveFromStart(start time.Time)

ObserveFromStart implements ScalableHistogram.

func (MultiHistogram) With

func (h MultiHistogram) With(labelValues ...string) ScalableHistogram

With implements ScalableHistogram.

type PilotMetric

type PilotMetric struct {
	Name         string                 `json:"name"`
	Type         string                 `json:"type"`
	Observations map[string]interface{} `json:"observations"`
}

PilotMetric is a representation of a metric.

type PilotRegistry

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

PilotRegistry represents the pilots metrics registry.

func RegisterPilot

func RegisterPilot() *PilotRegistry

RegisterPilot registers all Pilot metrics.

func (PilotRegistry) ConfigReloadsCounter

func (r PilotRegistry) ConfigReloadsCounter() metrics.Counter

func (PilotRegistry) ConfigReloadsFailureCounter

func (r PilotRegistry) ConfigReloadsFailureCounter() metrics.Counter

func (*PilotRegistry) Data

func (pr *PilotRegistry) Data() []PilotMetric

Data exports the metrics: metrics name -> labels -> values.

func (PilotRegistry) EntryPointOpenConnsGauge

func (r PilotRegistry) EntryPointOpenConnsGauge() metrics.Gauge

func (PilotRegistry) EntryPointReqDurationHistogram

func (r PilotRegistry) EntryPointReqDurationHistogram() ScalableHistogram

func (PilotRegistry) EntryPointReqsCounter

func (r PilotRegistry) EntryPointReqsCounter() metrics.Counter

func (PilotRegistry) EntryPointReqsTLSCounter

func (r PilotRegistry) EntryPointReqsTLSCounter() metrics.Counter

func (PilotRegistry) IsEpEnabled

func (r PilotRegistry) IsEpEnabled() bool

func (PilotRegistry) IsSvcEnabled

func (r PilotRegistry) IsSvcEnabled() bool

func (PilotRegistry) LastConfigReloadFailureGauge

func (r PilotRegistry) LastConfigReloadFailureGauge() metrics.Gauge

func (PilotRegistry) LastConfigReloadSuccessGauge

func (r PilotRegistry) LastConfigReloadSuccessGauge() metrics.Gauge

func (PilotRegistry) ServiceOpenConnsGauge

func (r PilotRegistry) ServiceOpenConnsGauge() metrics.Gauge

func (PilotRegistry) ServiceReqDurationHistogram

func (r PilotRegistry) ServiceReqDurationHistogram() ScalableHistogram

func (PilotRegistry) ServiceReqsCounter

func (r PilotRegistry) ServiceReqsCounter() metrics.Counter

func (PilotRegistry) ServiceReqsTLSCounter

func (r PilotRegistry) ServiceReqsTLSCounter() metrics.Counter

func (PilotRegistry) ServiceRetriesCounter

func (r PilotRegistry) ServiceRetriesCounter() metrics.Counter

func (PilotRegistry) ServiceServerUpGauge

func (r PilotRegistry) ServiceServerUpGauge() metrics.Gauge

type Registry

type Registry interface {
	// IsEpEnabled shows whether metrics instrumentation is enabled on entry points.
	IsEpEnabled() bool
	// IsSvcEnabled shows whether metrics instrumentation is enabled on services.
	IsSvcEnabled() bool

	// server metrics
	ConfigReloadsCounter() metrics.Counter
	ConfigReloadsFailureCounter() metrics.Counter
	LastConfigReloadSuccessGauge() metrics.Gauge
	LastConfigReloadFailureGauge() metrics.Gauge

	// entry point metrics
	EntryPointReqsCounter() metrics.Counter
	EntryPointReqsTLSCounter() metrics.Counter
	EntryPointReqDurationHistogram() ScalableHistogram
	EntryPointOpenConnsGauge() metrics.Gauge

	// service metrics
	ServiceReqsCounter() metrics.Counter
	ServiceReqsTLSCounter() metrics.Counter
	ServiceReqDurationHistogram() ScalableHistogram
	ServiceOpenConnsGauge() metrics.Gauge
	ServiceRetriesCounter() metrics.Counter
	ServiceServerUpGauge() metrics.Gauge
}

Registry has to implemented by any system that wants to monitor and expose metrics.

func NewMultiRegistry

func NewMultiRegistry(registries []Registry) Registry

NewMultiRegistry is an implementation of metrics.Registry that wraps multiple registries. It handles the case when a registry hasn't registered some metric and returns nil. This allows for feature imparity between the different metric implementations.

func NewVoidRegistry

func NewVoidRegistry() Registry

NewVoidRegistry is a noop implementation of metrics.Registry. It is used to avoid nil checking in components that do metric collections.

func RegisterDatadog

func RegisterDatadog(ctx context.Context, config *types.Datadog) Registry

RegisterDatadog registers the metrics pusher if this didn't happen yet and creates a datadog Registry instance.

func RegisterInfluxDB

func RegisterInfluxDB(ctx context.Context, config *types.InfluxDB) Registry

RegisterInfluxDB registers the metrics pusher if this didn't happen yet and creates a InfluxDB Registry instance.

func RegisterPrometheus

func RegisterPrometheus(ctx context.Context, config *types.Prometheus) Registry

RegisterPrometheus registers all Prometheus metrics. It must be called only once and failing to register the metrics will lead to a panic.

func RegisterStatsd

func RegisterStatsd(ctx context.Context, config *types.Statsd) Registry

RegisterStatsd registers the metrics pusher if this didn't happen yet and creates a statsd Registry instance.

type ScalableHistogram

type ScalableHistogram interface {
	With(labelValues ...string) ScalableHistogram
	Observe(v float64)
	ObserveFromStart(start time.Time)
}

ScalableHistogram is a Histogram with a predefined time unit, used when producing observations without explicitly setting the observed value.

func NewHistogramWithScale

func NewHistogramWithScale(histogram metrics.Histogram, unit time.Duration) (ScalableHistogram, error)

NewHistogramWithScale returns a ScalableHistogram. It returns an error if the given unit is <= 0.

Jump to

Keyboard shortcuts

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