mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 21:47:07 +00:00
Merge pull request #4753 from vmarmol/mon
First Kubelet metric and overall plumbing.
This commit is contained in:
commit
c561c8b0b1
@ -38,6 +38,7 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/dockertools"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/envvars"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/envvars"
|
||||||
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/metrics"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/volume"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/kubelet/volume"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
|
||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/probe"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/probe"
|
||||||
@ -969,6 +970,11 @@ func (kl *Kubelet) createPodInfraContainer(pod *api.BoundPod) (dockertools.Docke
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (kl *Kubelet) pullImage(img string, ref *api.ObjectReference) error {
|
func (kl *Kubelet) pullImage(img string, ref *api.ObjectReference) error {
|
||||||
|
start := time.Now()
|
||||||
|
defer func() {
|
||||||
|
metrics.ImagePullLatency.Observe(float64(time.Since(start).Nanoseconds() / time.Microsecond.Nanoseconds()))
|
||||||
|
}()
|
||||||
|
|
||||||
if err := kl.dockerPuller.Pull(img); err != nil {
|
if err := kl.dockerPuller.Pull(img); err != nil {
|
||||||
if ref != nil {
|
if ref != nil {
|
||||||
record.Eventf(ref, "failed", "Failed to pull image %q", img)
|
record.Eventf(ref, "failed", "Failed to pull image %q", img)
|
||||||
|
59
pkg/kubelet/metrics/metrics.go
Normal file
59
pkg/kubelet/metrics/metrics.go
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2015 Google Inc. All rights reserved.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package metrics
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
)
|
||||||
|
|
||||||
|
const kubeletSubsystem = "kubelet"
|
||||||
|
|
||||||
|
var (
|
||||||
|
ImagePullLatency = prometheus.NewSummary(
|
||||||
|
prometheus.SummaryOpts{
|
||||||
|
Subsystem: kubeletSubsystem,
|
||||||
|
Name: "image_pull_latency_microseconds",
|
||||||
|
Help: "Image pull latency in microseconds.",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
// TODO(vmarmol): Implement.
|
||||||
|
// TODO(vmarmol): Split by source?
|
||||||
|
PodCount = prometheus.NewGauge(
|
||||||
|
prometheus.GaugeOpts{
|
||||||
|
Subsystem: kubeletSubsystem,
|
||||||
|
Name: "pod_count",
|
||||||
|
Help: "Number of pods currently running.",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
// TODO(vmarmol): Implement.
|
||||||
|
// TODO(vmarmol): Split by source?
|
||||||
|
ContainerCount = prometheus.NewGauge(
|
||||||
|
prometheus.GaugeOpts{
|
||||||
|
Subsystem: kubeletSubsystem,
|
||||||
|
Name: "container_count",
|
||||||
|
Help: "Number of containers currently running.",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
// TODO(vmarmol): Containers per pod
|
||||||
|
// TODO(vmarmol): Latency of pod startup
|
||||||
|
// TODO(vmarmol): Latency of SyncPods
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// Register the metrics.
|
||||||
|
prometheus.MustRegister(ImagePullLatency)
|
||||||
|
}
|
@ -39,6 +39,7 @@ import (
|
|||||||
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/httpstream/spdy"
|
"github.com/GoogleCloudPlatform/kubernetes/pkg/util/httpstream/spdy"
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
"github.com/google/cadvisor/info"
|
"github.com/google/cadvisor/info"
|
||||||
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Server is a http.Handler which exposes kubelet functionality over HTTP.
|
// Server is a http.Handler which exposes kubelet functionality over HTTP.
|
||||||
@ -110,6 +111,7 @@ func (s *Server) InstallDebuggingHandlers() {
|
|||||||
|
|
||||||
s.mux.HandleFunc("/logs/", s.handleLogs)
|
s.mux.HandleFunc("/logs/", s.handleLogs)
|
||||||
s.mux.HandleFunc("/containerLogs/", s.handleContainerLogs)
|
s.mux.HandleFunc("/containerLogs/", s.handleContainerLogs)
|
||||||
|
s.mux.Handle("/metrics", prometheus.Handler())
|
||||||
}
|
}
|
||||||
|
|
||||||
// error serializes an error object into an HTTP response.
|
// error serializes an error object into an HTTP response.
|
||||||
|
Loading…
Reference in New Issue
Block a user