Add 'apiserver_watch_events_sizes'.

That metric can be used to estimate the size of watch events sent out to
the clients.

Kubernetes-commit: 4af189aab9cca61d1a701133596f6f82b1ca0719
This commit is contained in:
Maciej Borsz 2019-07-23 12:55:11 +02:00 committed by Kubernetes Publisher
parent 8ea3085fc3
commit 9baeaec78d
2 changed files with 10 additions and 0 deletions

View File

@ -238,6 +238,7 @@ func (s *WatchServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
// type // type
unknown.Raw = buf.Bytes() unknown.Raw = buf.Bytes()
event.Object = &unknown event.Object = &unknown
metrics.WatchEventsSizes.WithLabelValues(kind.Group, kind.Version, kind.Kind).Observe(float64(len(unknown.Raw)))
*outEvent = metav1.WatchEvent{} *outEvent = metav1.WatchEvent{}

View File

@ -148,6 +148,14 @@ var (
}, },
[]string{"group", "version", "kind"}, []string{"group", "version", "kind"},
) )
WatchEventsSizes = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Name: "apiserver_watch_events_sizes",
Help: "Watch event size distribution in bytes",
Buckets: prometheus.ExponentialBuckets(1024, 2.0, 8), // 1K, 2K, 4K, 8K, ..., 128K.
},
[]string{"group", "version", "kind"},
)
// Because of volatality of the base metric this is pre-aggregated one. Instead of reporing current usage all the time // Because of volatality of the base metric this is pre-aggregated one. Instead of reporing current usage all the time
// it reports maximal usage during the last second. // it reports maximal usage during the last second.
currentInflightRequests = prometheus.NewGaugeVec( currentInflightRequests = prometheus.NewGaugeVec(
@ -171,6 +179,7 @@ var (
DeprecatedDroppedRequests, DeprecatedDroppedRequests,
RegisteredWatchers, RegisteredWatchers,
WatchEvents, WatchEvents,
WatchEventsSizes,
currentInflightRequests, currentInflightRequests,
} }
) )