nozzle

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2019 License: Apache-2.0, Apache-2.0 Imports: 23 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// MatchName matches the supplied regexp against the Envelope
	// origin and the metric name concatenated with ".", e.g.
	// "gorouter.total_requests".
	MatchName = "name"
	// MatchJob matches the supplied regexp against the Envelope job.
	MatchJob = "job"
)

Variables

This section is empty.

Functions

func ParseEvents

func ParseEvents(names []string) ([]events.Envelope_EventType, error)

Types

type CounterTracker

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

CounterTracker is used to provide a "start time" for each loggregator counter metric exported by the nozzle.

Stackdriver requires each point for a cumulative metric to include "start time" in addition to the actual event time (aka "end time"): https://cloud.google.com/monitoring/api/ref_v3/rest/v3/TimeSeries#point Typically start time would correspond to the time when the actual process exporting the metric started. This ensures that when a process is restarted (and counter gets reset to 0), start time increases.

Since binaries that export counter events to loggregator only provide event time, the nozzle needs to determine start time for each metric itself. To do that, CounterTracker keeps its own counter for each metric, which corresponds to the total number of events since the metric was first seen by the nozzle (which is exported as the start time).

As an example, a series of incoming CounterEvents with total values of [100, 110, 115, 150] will be exported by the nozzle as [10, 15, 50] (first point seen by the nozzle is discarded, because each point reported to Stackdriver needs to cover non-zero time interval between start time and end time).

If CounterTracker detects the total value for a given counter decrease, it will interpret this as a counter reset. This will not result in the Stackdriver cumulative metric being reset as well; for example, incoming CounterEvents with total values of [100, 110, 115, 10, 17] will be exported by the nozzle as [10, 15, 25, 32].

CounterTracker will regularly remove internal state for metrics that have not been seen for a while. This is done to conserve memory, and also to ensure that old values do not re-surface if a given counter stops being exported for some period of time.

func NewCounterTracker

func NewCounterTracker(ctx context.Context, ttl time.Duration, logger lager.Logger) *CounterTracker

NewCounterTracker creates and returns a counter tracker.

func (*CounterTracker) Update

func (t *CounterTracker) Update(name string, value uint64, eventTime time.Time) (int64, time.Time)

Update accepts a counter name, event time and a value, and returns the total value for the counter along with its start time. Counter name provided needs to uniquely identify the time series (so it needs to include metric name as well as all metric label values). At least two values need to be observed for a given counter to determine the total value, so for the first observed value, 0 will be returned as the total, and end time will be equal to event time. Such points should not be reported to Stackdriver, since it expects points covering non-zero time interval.

type EventFilter

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

An EventFilter can be used to specify regular expressions to match against event proto fields, for the purpose of blacklisting or whitelisting nozzle processing of firehose events.

func (*EventFilter) Add

func (ef *EventFilter) Add(mt, re string) error

Add adds a regular expression to the filter, matching against a particular set of event proto fields based on the match type.

func (*EventFilter) Len

func (ef *EventFilter) Len() int

Len returns the number of filters added to the EventFilter. Useful for external testing.

func (*EventFilter) Match

func (ef *EventFilter) Match(event *events.Envelope) bool

Match returns true if the provided event Envelope matches any of the filters added to the MetricFilter.

type LabelMaker

type LabelMaker interface {
	MetricLabels(*events.Envelope, bool) map[string]string
	LogLabels(*events.Envelope) map[string]string
}

func NewLabelMaker

func NewLabelMaker(appInfoRepository cloudfoundry.AppInfoRepository, foundationName string) LabelMaker

type Nozzle

type Nozzle interface {
	Start(rlp cloudfoundry.ReverseLogProxy)
	Stop() error
}

func NewNozzle

func NewNozzle(logger lager.Logger, sinks ...Sink) Nozzle

type Sink

type Sink interface {
	Receive(*events.Envelope)
}

func NewFilterSink added in v1.0.6

func NewFilterSink(eventNames []events.Envelope_EventType, blacklist, whitelist *EventFilter, destination Sink) (Sink, error)

func NewHTTPSink

func NewHTTPSink(logger lager.Logger, labelMaker LabelMaker) Sink

NewHTTPSink returns a Sink that can receive sonde HttpStartStop events and generate per-application HTTP metrics from them.

func NewLogSink

func NewLogSink(labelMaker LabelMaker, logAdapter stackdriver.LogAdapter, newlineToken string, logger lager.Logger) Sink

NewLogSink returns a Sink that can receive sonde Events, translate them and send them to a stackdriver.LogAdapter

func NewMetricSink

func NewMetricSink(logger lager.Logger, pathPrefix string, labelMaker LabelMaker, metricAdapter stackdriver.MetricAdapter, ct *CounterTracker, unitParser UnitParser, runtimeMetricRegex string) (Sink, error)

NewLogSink returns a Sink that can receive sonde Events, translate them and send them to a stackdriver.MetricAdapter

type UnitParser

type UnitParser interface {
	Parse(string) string
}

func NewUnitParser

func NewUnitParser() UnitParser

Jump to

Keyboard shortcuts

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