telemetry

package
Version: v2.0.0-beta.5 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2020 License: MIT Imports: 13 Imported by: 0

README

Telemetry Data

Telemetry is first collected by retrieving prometheus data from a Gatherer. Next, the collected data is filtered by matching a subset of prometheus families. Finally, the data is transmitted to a prometheus push gateway handler.

The handler enriches the metrics with the timestamp when the data is received.

Documentation

Index

Constants

View Source
const (
	// DefaultTimeout is the length of time servicing the metrics before canceling.
	DefaultTimeout = 10 * time.Second
	// DefaultMaxBytes is the largest request body read.
	DefaultMaxBytes = 1024000
)

Variables

View Source
var (
	// ErrMetricsTimestampPresent is returned when the prometheus metrics has timestamps set.
	// Not sure why, but, pushgateway does not allow timestamps.
	ErrMetricsTimestampPresent = fmt.Errorf("pushed metrics must not have timestamp")
)

Functions

This section is empty.

Types

type AddTimestamps

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

AddTimestamps enriches prometheus metrics by adding timestamps.

func (*AddTimestamps) Transform

func (a *AddTimestamps) Transform(mfs []*dto.MetricFamily) []*dto.MetricFamily

Transform adds now as a timestamp to all metrics.

type LogStore

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

LogStore logs data written to the store.

func NewLogStore

func NewLogStore(log *zap.Logger) *LogStore

func (*LogStore) WriteMessage

func (s *LogStore) WriteMessage(ctx context.Context, data []byte) error

WriteMessage logs data at Info level.

type PushGateway

type PushGateway struct {
	Timeout  time.Duration // handler returns after this duration with an error; defaults to 5 seconds
	MaxBytes int64         // maximum number of bytes to read from the body; defaults to 1024000

	Store        Store
	Transformers []prometheus.Transformer

	Encoder prometheus.Encoder
	// contains filtered or unexported fields
}

PushGateway handles receiving prometheus push metrics and forwards them to the Store. If Format is not set, the format of the inbound metrics are used.

func NewPushGateway

func NewPushGateway(log *zap.Logger, store Store, xforms ...prometheus.Transformer) *PushGateway

NewPushGateway constructs the PushGateway.

func (*PushGateway) Handler

func (p *PushGateway) Handler(w http.ResponseWriter, r *http.Request)

Handler accepts prometheus metrics send via the Push client and sends those metrics into the store.

type Pusher

type Pusher struct {
	URL        string
	Gather     prometheus.Gatherer
	Client     *http.Client
	PushFormat expfmt.Format
}

Pusher pushes metrics to a prometheus push gateway.

func NewPusher

func NewPusher(g prometheus.Gatherer) *Pusher

NewPusher sends usage metrics to a prometheus push gateway.

func (*Pusher) Push

func (p *Pusher) Push(ctx context.Context) error

Push POSTs prometheus metrics in protobuf delimited format to a push gateway.

type Reporter

type Reporter struct {
	Pusher *Pusher

	Interval time.Duration
	// contains filtered or unexported fields
}

Reporter reports telemetry metrics to a prometheus push gateway every interval.

func NewReporter

func NewReporter(log *zap.Logger, g prometheus.Gatherer) *Reporter

NewReporter reports telemetry every 24 hours.

func (*Reporter) Report

func (r *Reporter) Report(ctx context.Context)

Report starts periodic telemetry reporting each interval.

type Store

type Store interface {
	// WriteMessage stores data into the store.
	WriteMessage(ctx context.Context, data []byte) error
}

Store records usage data.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL