apiserver: k8s.io/apiserver/pkg/endpoints/metrics Index | Files

package metrics

import "k8s.io/apiserver/pkg/endpoints/metrics"


Package Files



const (
    APIServerComponent string = "apiserver"
    OtherContentType   string = "other"
    OtherRequestMethod string = "other"
const (
    // ReadOnlyKind is a string identifying read only request kind
    ReadOnlyKind = "readOnly"
    // MutatingKind is a string identifying mutating request kind
    MutatingKind = "mutating"


var (

    // DroppedRequests is a number of requests dropped with 'Try again later' response"
    DroppedRequests = compbasemetrics.NewCounterVec(
            Name:           "apiserver_dropped_requests_total",
            Help:           "Number of requests dropped with 'Try again later' response",
            StabilityLevel: compbasemetrics.ALPHA,
    // RegisteredWatchers is a number of currently registered watchers splitted by resource.
    RegisteredWatchers = compbasemetrics.NewGaugeVec(
            Name:           "apiserver_registered_watchers",
            Help:           "Number of currently registered watchers for a given resources",
            StabilityLevel: compbasemetrics.ALPHA,
        []string{"group", "version", "kind"},
    WatchEvents = compbasemetrics.NewCounterVec(
            Name:           "apiserver_watch_events_total",
            Help:           "Number of events sent in watch clients",
            StabilityLevel: compbasemetrics.ALPHA,
        []string{"group", "version", "kind"},
    WatchEventsSizes = compbasemetrics.NewHistogramVec(
            Name:           "apiserver_watch_events_sizes",
            Help:           "Watch event size distribution in bytes",
            Buckets:        compbasemetrics.ExponentialBuckets(1024, 2.0, 8),
            StabilityLevel: compbasemetrics.ALPHA,
        []string{"group", "version", "kind"},

* By default, all the following metrics are defined as falling under * ALPHA stability level https://github.com/kubernetes/enhancements/blob/master/keps/sig-instrumentation/20190404-kubernetes-control-plane-metrics-stability.md#stability-classes) * * Promoting the stability level of the metric is a responsibility of the component owner, since it * involves explicitly acknowledging support for the metric across multiple releases, in accordance with * the metric stability policy.

func CleanScope Uses

func CleanScope(requestInfo *request.RequestInfo) string

CleanScope returns the scope of the request.

func InstrumentHandlerFunc Uses

func InstrumentHandlerFunc(verb, group, version, resource, subresource, scope, component string, deprecated bool, removedRelease string, handler http.HandlerFunc) http.HandlerFunc

InstrumentHandlerFunc works like Prometheus' InstrumentHandlerFunc but adds some Kubernetes endpoint specific information.

func InstrumentRouteFunc Uses

func InstrumentRouteFunc(verb, group, version, resource, subresource, scope, component string, deprecated bool, removedRelease string, routeFunc restful.RouteFunction) restful.RouteFunction

InstrumentRouteFunc works like Prometheus' InstrumentHandlerFunc but wraps the go-restful RouteFunction instead of a HandlerFunc plus some Kubernetes endpoint specific information.

func MonitorRequest Uses

func MonitorRequest(req *http.Request, verb, group, version, resource, subresource, scope, component string, deprecated bool, removedRelease string, contentType string, httpCode, respSize int, elapsed time.Duration)

MonitorRequest handles standard transformations for client and the reported verb and then invokes Monitor to record a request. verb must be uppercase to be backwards compatible with existing monitoring tooling.

func RecordLongRunning Uses

func RecordLongRunning(req *http.Request, requestInfo *request.RequestInfo, component string, fn func())

RecordLongRunning tracks the execution of a long running request against the API server. It provides an accurate count of the total number of open long running requests. requestInfo may be nil if the caller is not in the normal request flow.

func RecordRequestTermination Uses

func RecordRequestTermination(req *http.Request, requestInfo *request.RequestInfo, component string, code int)

RecordRequestTermination records that the request was terminated early as part of a resource preservation or apiserver self-defense mechanism (e.g. timeouts, maxinflight throttling, proxyHandler errors). RecordRequestTermination should only be called zero or one times per request.

func Register Uses

func Register()

Register all metrics.

func Reset Uses

func Reset()

Reset all metrics.

func UpdateInflightRequestMetrics Uses

func UpdateInflightRequestMetrics(nonmutating, mutating int)

type ResponseWriterDelegator Uses

type ResponseWriterDelegator struct {
    // contains filtered or unexported fields

ResponseWriterDelegator interface wraps http.ResponseWriter to additionally record content-length, status-code, etc.

func (*ResponseWriterDelegator) ContentLength Uses

func (r *ResponseWriterDelegator) ContentLength() int

func (*ResponseWriterDelegator) Status Uses

func (r *ResponseWriterDelegator) Status() int

func (*ResponseWriterDelegator) Write Uses

func (r *ResponseWriterDelegator) Write(b []byte) (int, error)

func (*ResponseWriterDelegator) WriteHeader Uses

func (r *ResponseWriterDelegator) WriteHeader(code int)

Package metrics imports 18 packages (graph) and is imported by 14 packages. Updated 2020-06-20. Refresh now. Tools for package owners.