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
- func NewHandler(o Options) http.Handler
- type Metrics
- func (m *Metrics) IncCounter(key string)
- func (m *Metrics) IncErrorsBackend(routeId string)
- func (m *Metrics) IncErrorsStreaming(routeId string)
- func (m *Metrics) IncRoutingFailures()
- func (m *Metrics) MeasureAllFiltersRequest(routeId string, start time.Time)
- func (m *Metrics) MeasureAllFiltersResponse(routeId string, start time.Time)
- func (m *Metrics) MeasureBackend(routeId string, start time.Time)
- func (m *Metrics) MeasureBackend5xx(t time.Time)
- func (m *Metrics) MeasureBackendHost(routeBackendHost string, start time.Time)
- func (m *Metrics) MeasureFilterRequest(filterName string, start time.Time)
- func (m *Metrics) MeasureFilterResponse(filterName string, start time.Time)
- func (m *Metrics) MeasureResponse(code int, method string, routeId string, start time.Time)
- func (m *Metrics) MeasureRouteLookup(start time.Time)
- func (m *Metrics) MeasureServe(routeId, host, method string, code int, start time.Time)
- func (m *Metrics) MeasureSince(key string, start time.Time)
- type Options
Constants ¶
const ( KeyRouteLookup = "routelookup" KeyRouteFailure = "routefailure" KeyFilterRequest = "filter.%s.request" KeyFiltersRequest = "allfilters.request.%s" KeyAllFiltersRequestCombined = "allfilters.combined.request" KeyProxyBackend = "backend.%s" KeyProxyBackendCombined = "all.backend" KeyProxyBackendHost = "backendhost.%s" KeyFilterResponse = "filter.%s.response" KeyFiltersResponse = "allfilters.response.%s" KeyAllFiltersResponseCombined = "allfilters.combined.response" KeyResponse = "response.%d.%s.skipper.%s" KeyResponseCombined = "all.response.%d.%s.skipper" KeyServeRoute = "serveroute.%s.%s.%d" KeyServeHost = "servehost.%s.%s.%d" Key5xxsBackend = "all.backend.5xx" KeyErrorsBackend = "errors.backend.%s" KeyErrorsStreaming = "errors.streaming.%s" )
Variables ¶
This section is empty.
Functions ¶
func NewHandler ¶ added in v0.9.62
NewHandler returns a collection of metrics handlers.
Types ¶
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
func (*Metrics) IncCounter ¶ added in v0.9.86
func (*Metrics) IncErrorsBackend ¶
func (*Metrics) IncErrorsStreaming ¶
func (*Metrics) IncRoutingFailures ¶
func (m *Metrics) IncRoutingFailures()
func (*Metrics) MeasureAllFiltersRequest ¶
func (*Metrics) MeasureAllFiltersResponse ¶
func (*Metrics) MeasureBackend5xx ¶ added in v0.9.103
func (*Metrics) MeasureBackendHost ¶
func (*Metrics) MeasureFilterRequest ¶
func (*Metrics) MeasureFilterResponse ¶
func (*Metrics) MeasureResponse ¶
func (*Metrics) MeasureRouteLookup ¶
func (*Metrics) MeasureServe ¶
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 // UseExpDecaySample, when set, makes the histograms use an exponentially // decaying sample instead of the default uniform one. UseExpDecaySample 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.