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 Init(o Options)
- type Metrics
- 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) 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)
- type Options
Constants ¶
const ( KeyRouteLookup = "routelookup" KeyRouteFailure = "routefailure" KeyFilterRequest = "filter.%s.request" KeyFiltersRequest = "allfilters.request.%s" KeyProxyBackend = "backend.%s" KeyProxyBackendHost = "backendhost.%s" KeyFilterResponse = "filter.%s.response" KeyFiltersResponse = "allfilters.response.%s" KeyResponse = "response.%d.%s.skipper.%s" KeyServeRoute = "serveroute.%s.%s.%d" KeyServeHost = "servehost.%s.%s.%d" KeyErrorsBackend = "errors.backend.%s" KeyErrorsStreaming = "errors.streaming.%s" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
func (*Metrics) IncErrorsBackend ¶
func (*Metrics) IncErrorsStreaming ¶
func (*Metrics) IncRoutingFailures ¶
func (m *Metrics) IncRoutingFailures()
func (*Metrics) MeasureAllFiltersRequest ¶
func (*Metrics) MeasureAllFiltersResponse ¶
func (*Metrics) MeasureBackendHost ¶
func (*Metrics) MeasureFilterRequest ¶
func (*Metrics) MeasureFilterResponse ¶
func (*Metrics) MeasureResponse ¶
func (*Metrics) MeasureRouteLookup ¶
type Options ¶
type Options struct { // Network address where the current metrics values // can be pulled from. If not set, the collection of // the metrics is disabled. Listener string // 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 // EnableProfile exposes profiling information on /pprof of the // metrics listener. EnableProfile bool }
Options for initializing metrics collection.