Add 'apiserver_watch_events_total' metric.

We found this metric useful to understand the CPU usage of the
kube-apiserver process.
This commit is contained in:
Maciej Borsz 2019-06-05 14:27:09 +02:00
parent 88f8c785b4
commit 58d3338ddd
2 changed files with 8 additions and 0 deletions

View File

@ -225,6 +225,7 @@ func (s *WatchServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
// End of results.
return
}
metrics.WatchEvents.WithLabelValues(kind.Group, kind.Version, kind.Kind).Inc()
obj := s.Fixup(event.Object)
if err := s.EmbeddedEncoder.Encode(obj, buf); err != nil {

View File

@ -141,6 +141,13 @@ var (
},
[]string{"group", "version", "kind"},
)
WatchEvents = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "apiserver_watch_events_total",
Help: "Number of events sent in watch clients",
},
[]string{"group", "version", "kind"},
)
// 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.
currentInflightRequests = prometheus.NewGaugeVec(