mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
Merge pull request #77759 from haiyanmeng/host
Remove the `host` label from the kubelet http traffic metrics
This commit is contained in:
commit
2525ab8572
@ -38,7 +38,7 @@ var (
|
||||
// server_type aims to differentiate the readonly server and the readwrite server.
|
||||
// long_running marks whether the request is long-running or not.
|
||||
// Currently, long-running requests include exec/attach/portforward/debug.
|
||||
[]string{"method", "path", "host", "server_type", "long_running"},
|
||||
[]string{"method", "path", "server_type", "long_running"},
|
||||
)
|
||||
// HTTPRequestsDuration tracks the duration in seconds to serve http requests.
|
||||
HTTPRequestsDuration = prometheus.NewHistogramVec(
|
||||
@ -49,7 +49,7 @@ var (
|
||||
// Use DefBuckets for now, will customize the buckets if necessary.
|
||||
Buckets: prometheus.DefBuckets,
|
||||
},
|
||||
[]string{"method", "path", "host", "server_type", "long_running"},
|
||||
[]string{"method", "path", "server_type", "long_running"},
|
||||
)
|
||||
// HTTPInflightRequests tracks the number of the inflight http requests.
|
||||
HTTPInflightRequests = prometheus.NewGaugeVec(
|
||||
@ -58,7 +58,7 @@ var (
|
||||
Name: "http_inflight_requests",
|
||||
Help: "Number of the inflight http requests",
|
||||
},
|
||||
[]string{"method", "path", "host", "server_type", "long_running"},
|
||||
[]string{"method", "path", "server_type", "long_running"},
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -859,17 +859,17 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||
serverType = "readwrite"
|
||||
}
|
||||
|
||||
method, path, host := req.Method, trimURLPath(req.URL.Path), req.URL.Host
|
||||
method, path := req.Method, trimURLPath(req.URL.Path)
|
||||
|
||||
longRunning := strconv.FormatBool(isLongRunningRequest(path))
|
||||
|
||||
servermetrics.HTTPRequests.WithLabelValues(method, path, host, serverType, longRunning).Inc()
|
||||
servermetrics.HTTPRequests.WithLabelValues(method, path, serverType, longRunning).Inc()
|
||||
|
||||
servermetrics.HTTPInflightRequests.WithLabelValues(method, path, host, serverType, longRunning).Inc()
|
||||
defer servermetrics.HTTPInflightRequests.WithLabelValues(method, path, host, serverType, longRunning).Dec()
|
||||
servermetrics.HTTPInflightRequests.WithLabelValues(method, path, serverType, longRunning).Inc()
|
||||
defer servermetrics.HTTPInflightRequests.WithLabelValues(method, path, serverType, longRunning).Dec()
|
||||
|
||||
startTime := time.Now()
|
||||
defer servermetrics.HTTPRequestsDuration.WithLabelValues(method, path, host, serverType, longRunning).Observe(servermetrics.SinceInSeconds(startTime))
|
||||
defer servermetrics.HTTPRequestsDuration.WithLabelValues(method, path, serverType, longRunning).Observe(servermetrics.SinceInSeconds(startTime))
|
||||
|
||||
s.restfulCont.ServeHTTP(w, req)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user