prometheus

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultPrometheusOpts is the default set of options used when creating a
	// PrometheusSink.
	DefaultPrometheusOpts = PrometheusOpts{
		Expiration: 60 * time.Second,
	}
)

Functions

This section is empty.

Types

type CounterDefinition

type CounterDefinition struct {
	Name        []string
	ConstLabels []metrics.Label
	Help        string
}

CounterDefinition can be provided to PrometheusOpts to declare a constant counter that is not deleted on expiry.

type GaugeDefinition

type GaugeDefinition struct {
	Name        []string
	ConstLabels []metrics.Label
	Help        string
}

GaugeDefinition can be provided to PrometheusOpts to declare a constant gauge that is not deleted on expiry.

type PrometheusOpts

type PrometheusOpts struct {
	// Expiration is the duration a metric is valid for, after which it will be
	// untracked. If the value is zero, a metric is never expired.
	Expiration time.Duration
	Registerer prometheus.Registerer

	// Gauges, Summaries, and Counters allow us to pre-declare metrics by giving their Name, Help, and ConstLabels to
	// the PrometheusSink when it is created. Metrics declared in this way will be initialized at zero and will not be
	// deleted when their expiry is reached.
	// - Gauges and Summaries will be set to NaN when they expire.
	// - Counters continue to Collect their last known value.
	// Ex:
	// PrometheusOpts{
	//     Expiration: 10 * time.Second,
	//     Gauges: []GaugeDefinition{
	//         {
	//	         Name: []string{ "application", "component", "measurement"},
	//           Help: "application_component_measurement provides an example of how to declare static metrics",
	//           ConstLabels: []metrics.Label{ { Name: "my_label", Value: "does_not_change" }, },
	//         },
	//     },
	// }
	GaugeDefinitions   []GaugeDefinition
	SummaryDefinitions []SummaryDefinition
	CounterDefinitions []CounterDefinition
}

PrometheusOpts is used to configure the Prometheus Sink

type PrometheusPushSink

type PrometheusPushSink struct {
	*PrometheusSink
	// contains filtered or unexported fields
}

PrometheusPushSink wraps a normal prometheus sink and provides an address and facilities to export it to an address on an interval.

func NewPrometheusPushSink

func NewPrometheusPushSink(address string, pushInterval time.Duration, name string) (*PrometheusPushSink, error)

NewPrometheusPushSink creates a PrometheusPushSink by taking an address, interval, and destination name.

func (*PrometheusPushSink) Shutdown

func (s *PrometheusPushSink) Shutdown()

type PrometheusSink

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

func NewPrometheusSink

func NewPrometheusSink() (*PrometheusSink, error)

NewPrometheusSink creates a new PrometheusSink using the default options.

func NewPrometheusSinkFrom

func NewPrometheusSinkFrom(opts PrometheusOpts) (*PrometheusSink, error)

NewPrometheusSinkFrom creates a new PrometheusSink using the passed options.

func (*PrometheusSink) AddSample

func (p *PrometheusSink) AddSample(parts []string, val float32)

func (*PrometheusSink) AddSampleWithLabels

func (p *PrometheusSink) AddSampleWithLabels(parts []string, val float32, labels []metrics.Label)

func (*PrometheusSink) Collect

func (p *PrometheusSink) Collect(c chan<- prometheus.Metric)

Collect meets the collection interface and allows us to enforce our expiration logic to clean up ephemeral metrics if their value haven't been set for a duration exceeding our allowed expiration time.

func (*PrometheusSink) Describe

func (p *PrometheusSink) Describe(c chan<- *prometheus.Desc)

Describe is needed to meet the Collector interface.

func (*PrometheusSink) EmitKey

func (p *PrometheusSink) EmitKey(key []string, val float32)

EmitKey is not implemented. Prometheus doesn’t offer a type for which an arbitrary number of values is retained, as Prometheus works with a pull model, rather than a push model.

func (*PrometheusSink) IncrCounter

func (p *PrometheusSink) IncrCounter(parts []string, val float32)

func (*PrometheusSink) IncrCounterWithLabels

func (p *PrometheusSink) IncrCounterWithLabels(parts []string, val float32, labels []metrics.Label)

func (*PrometheusSink) SetGauge

func (p *PrometheusSink) SetGauge(parts []string, val float32)

func (*PrometheusSink) SetGaugeWithLabels

func (p *PrometheusSink) SetGaugeWithLabels(parts []string, val float32, labels []metrics.Label)

type SummaryDefinition

type SummaryDefinition struct {
	Name        []string
	ConstLabels []metrics.Label
	Help        string
}

SummaryDefinition can be provided to PrometheusOpts to declare a constant summary that is not deleted on expiry.

Jump to

Keyboard shortcuts

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