metrics

package
v0.9.94 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2017 License: Apache-2.0, MIT Imports: 8 Imported by: 0

Documentation

Overview

Package metrics implements collection of common performance metrics.

It uses the Go implementation of the Coda Hale metrics library:

https://github.com/dropwizard/metrics https://github.com/rcrowley/go-metrics

The collected metrics include detailed information about Skipper's relevant processes while serving requests - looking up routes, filters (aggregate and individual), backend communication and forwarding the response to the client.

Options

To enable metrics, it needs to be initialized with a Listener address. In this case, Skipper will start an additional http listener, where the current metrics values can be downloaded.

You can define a custom Prefix to every reported metrics key. This allows you to avoid conflicts between Skipper's metrics and other systems if you aggregate them later in some monitoring system. The default prefix is "skipper."

You can also enable some Go garbage collector and runtime metrics using EnableDebugGcMetrics and EnableRuntimeMetrics, respectively.

REST API

This listener accepts GET requests on the /metrics endpoint like any other REST api. A request to "/metrics" should return a JSON response including all the collected metrics. Please note that a lot of metrics are created lazily whenever a request triggers them. This means that the API response will depend on the current routes and the filters used. In the case there are no metrics due to inactivity, the API will return 404.

You can also query for specific metrics, individually or by prefix matching. You can either use the metrics key name and you should get back only the values for that particular key or a prefix in which case you should get all the metrics that share the same prefix.

If you request an unknown key or prefix the response will be an HTTP 404.

Index

Constants

View Source
const (
	KeyRouteLookup          = "routelookup"
	KeyRouteFailure         = "routefailure"
	KeyFilterRequest        = "filter.%s.request"
	KeyFiltersRequest       = "allfilters.request.%s"
	KeyProxyBackend         = "backend.%s"
	KeyProxyBackendCombined = "all.backend"
	KeyProxyBackendHost     = "backendhost.%s"
	KeyFilterResponse       = "filter.%s.response"
	KeyFiltersResponse      = "allfilters.response.%s"
	KeyResponse             = "response.%d.%s.skipper.%s"
	KeyResponseCombined     = "all.response.%d.%s.skipper"
	KeyServeRoute           = "serveroute.%s.%s.%d"
	KeyServeHost            = "servehost.%s.%s.%d"

	KeyErrorsBackend   = "errors.backend.%s"
	KeyErrorsStreaming = "errors.streaming.%s"
)

Variables

This section is empty.

Functions

func NewHandler added in v0.9.61

func NewHandler(o Options) http.Handler

NewHandler returns a collection of metrics handlers.

Types

type Metrics

type Metrics struct {
	// contains filtered or unexported fields
}
var (
	Default *Metrics
	Void    *Metrics
)

func New

func New(o Options) *Metrics

func NewVoid

func NewVoid() *Metrics

func (*Metrics) IncCounter added in v0.9.86

func (m *Metrics) IncCounter(key string)

func (*Metrics) IncErrorsBackend

func (m *Metrics) IncErrorsBackend(routeId string)

func (*Metrics) IncErrorsStreaming

func (m *Metrics) IncErrorsStreaming(routeId string)

func (*Metrics) IncRoutingFailures

func (m *Metrics) IncRoutingFailures()

func (*Metrics) MeasureAllFiltersRequest

func (m *Metrics) MeasureAllFiltersRequest(routeId string, start time.Time)

func (*Metrics) MeasureAllFiltersResponse

func (m *Metrics) MeasureAllFiltersResponse(routeId string, start time.Time)

func (*Metrics) MeasureBackend

func (m *Metrics) MeasureBackend(routeId string, start time.Time)

func (*Metrics) MeasureBackendHost

func (m *Metrics) MeasureBackendHost(routeBackendHost string, start time.Time)

func (*Metrics) MeasureFilterRequest

func (m *Metrics) MeasureFilterRequest(filterName string, start time.Time)

func (*Metrics) MeasureFilterResponse

func (m *Metrics) MeasureFilterResponse(filterName string, start time.Time)

func (*Metrics) MeasureResponse

func (m *Metrics) MeasureResponse(code int, method string, routeId string, start time.Time)

func (*Metrics) MeasureRouteLookup

func (m *Metrics) MeasureRouteLookup(start time.Time)

func (*Metrics) MeasureServe

func (m *Metrics) MeasureServe(routeId, host, method string, code int, start time.Time)

func (*Metrics) MeasureSince added in v0.9.86

func (m *Metrics) MeasureSince(key string, start time.Time)

type Options

type Options struct {
	// Common prefix for the keys of the different
	// collected metrics.
	Prefix string

	// If set, garbage collector metrics are collected
	// in addition to the http traffic metrics.
	EnableDebugGcMetrics bool

	// If set, Go runtime metrics are collected in
	// addition to the http traffic metrics.
	EnableRuntimeMetrics bool

	// If set, detailed total response time metrics will be collected
	// for each route, additionally grouped by status and method.
	EnableServeRouteMetrics bool

	// If set, detailed total response time metrics will be collected
	// for each host, additionally grouped by status and method.
	EnableServeHostMetrics bool

	// If set, detailed response time metrics will be collected
	// for each backend host
	EnableBackendHostMetrics bool

	// EnableAllFiltersMetrics enables collecting combined filter
	// metrics per each route. Without the DisableCompatibilityDefaults,
	// it is enabled by default.
	EnableAllFiltersMetrics bool

	// EnableCombinedResponseMetrics enables collecting response time
	// metrics combined for every route.
	EnableCombinedResponseMetrics bool

	// EnableRouteResponseMetrics enables collecting response time
	// metrics per each route. Without the DisableCompatibilityDefaults,
	// it is enabled by default.
	EnableRouteResponseMetrics bool

	// EnableRouteBackendErrorsCounters enables counters for backend
	// errors per each route. Without the DisableCompatibilityDefaults,
	// it is enabled by default.
	EnableRouteBackendErrorsCounters bool

	// EnableRouteStreamingErrorsCounters enables counters for streaming
	// errors per each route. Without the DisableCompatibilityDefaults,
	// it is enabled by default.
	EnableRouteStreamingErrorsCounters bool

	// EnableRouteBackendMetrics enables backend response time metrics
	// per each route. Without the DisableCompatibilityDefaults, it is
	// enabled by default.
	EnableRouteBackendMetrics bool

	// The following options, for backwards compatibility, are true
	// by default: EnableAllFiltersMetrics, EnableRouteResponseMetrics,
	// EnableRouteBackendErrorsCounters, EnableRouteStreamingErrorsCounters,
	// EnableRouteBackendMetrics. With this compatibility flag, the default
	// for these options can be set to false.
	DisableCompatibilityDefaults bool

	// EnableProfile exposes profiling information on /pprof of the
	// metrics listener.
	EnableProfile bool
}

Options for initializing metrics collection.

Jump to

Keyboard shortcuts

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