Report scope on all apiserver metrics

Counting list of namespaces is != list across all namespaces (same for
latency)
This commit is contained in:
Clayton Coleman 2017-09-09 14:02:19 -04:00
parent 5e46d5b545
commit 545aba778d
No known key found for this signature in database
GPG Key ID: 3D16906B4F1C5CB3

View File

@ -41,7 +41,7 @@ var (
Name: "apiserver_request_count", Name: "apiserver_request_count",
Help: "Counter of apiserver requests broken out for each verb, API resource, client, and HTTP response contentType and code.", Help: "Counter of apiserver requests broken out for each verb, API resource, client, and HTTP response contentType and code.",
}, },
[]string{"verb", "resource", "subresource", "client", "contentType", "code"}, []string{"verb", "resource", "subresource", "scope", "client", "contentType", "code"},
) )
requestLatencies = prometheus.NewHistogramVec( requestLatencies = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ prometheus.HistogramOpts{
@ -50,7 +50,7 @@ var (
// Use buckets ranging from 125 ms to 8 seconds. // Use buckets ranging from 125 ms to 8 seconds.
Buckets: prometheus.ExponentialBuckets(125000, 2.0, 7), Buckets: prometheus.ExponentialBuckets(125000, 2.0, 7),
}, },
[]string{"verb", "resource", "subresource"}, []string{"verb", "resource", "subresource", "scope"},
) )
requestLatenciesSummary = prometheus.NewSummaryVec( requestLatenciesSummary = prometheus.NewSummaryVec(
prometheus.SummaryOpts{ prometheus.SummaryOpts{
@ -59,7 +59,7 @@ var (
// Make the sliding window of 1h. // Make the sliding window of 1h.
MaxAge: time.Hour, MaxAge: time.Hour,
}, },
[]string{"verb", "resource", "subresource"}, []string{"verb", "resource", "subresource", "scope"},
) )
responseSizes = prometheus.NewHistogramVec( responseSizes = prometheus.NewHistogramVec(
prometheus.HistogramOpts{ prometheus.HistogramOpts{
@ -85,9 +85,9 @@ func Register() {
// uppercase to be backwards compatible with existing monitoring tooling. // uppercase to be backwards compatible with existing monitoring tooling.
func Monitor(verb, resource, subresource, scope, client, contentType string, httpCode, respSize int, reqStart time.Time) { func Monitor(verb, resource, subresource, scope, client, contentType string, httpCode, respSize int, reqStart time.Time) {
elapsed := float64((time.Since(reqStart)) / time.Microsecond) elapsed := float64((time.Since(reqStart)) / time.Microsecond)
requestCounter.WithLabelValues(verb, resource, subresource, client, contentType, codeToString(httpCode)).Inc() requestCounter.WithLabelValues(verb, resource, subresource, scope, client, contentType, codeToString(httpCode)).Inc()
requestLatencies.WithLabelValues(verb, resource, subresource).Observe(elapsed) requestLatencies.WithLabelValues(verb, resource, subresource, scope).Observe(elapsed)
requestLatenciesSummary.WithLabelValues(verb, resource, subresource).Observe(elapsed) requestLatenciesSummary.WithLabelValues(verb, resource, subresource, scope).Observe(elapsed)
// We are only interested in response sizes of read requests. // We are only interested in response sizes of read requests.
if verb == "GET" || verb == "LIST" { if verb == "GET" || verb == "LIST" {
responseSizes.WithLabelValues(verb, resource, subresource, scope).Observe(float64(respSize)) responseSizes.WithLabelValues(verb, resource, subresource, scope).Observe(float64(respSize))