Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record pleg pod relist interval and latency #19017

Merged
merged 1 commit into from
Jan 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions pkg/kubelet/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const (
DockerOperationsKey = "docker_operations_latency_microseconds"
DockerErrorsKey = "docker_errors"
PodWorkerStartLatencyKey = "pod_worker_start_latency_microseconds"
PLEGRelistLatencyKey = "pleg_relist_latency_microseconds"
PLEGRelistIntervalKey = "pleg_relist_interval_microseconds"
)

var (
Expand Down Expand Up @@ -105,6 +107,20 @@ var (
},
[]string{"operation_type"},
)
PLEGRelistLatency = prometheus.NewSummary(
prometheus.SummaryOpts{
Subsystem: KubeletSubsystem,
Name: PLEGRelistLatencyKey,
Help: "Latency in microseconds for relisting pods in PLEG.",
},
)
PLEGRelistInterval = prometheus.NewSummary(
prometheus.SummaryOpts{
Subsystem: KubeletSubsystem,
Name: PLEGRelistIntervalKey,
Help: "Interval in microseconds between relisting in PLEG.",
},
)
)

var registerMetrics sync.Once
Expand All @@ -123,6 +139,8 @@ func Register(containerCache kubecontainer.RuntimeCache) {
prometheus.MustRegister(ContainersPerPodCount)
prometheus.MustRegister(DockerErrors)
prometheus.MustRegister(newPodAndContainerCollector(containerCache))
prometheus.MustRegister(PLEGRelistLatency)
prometheus.MustRegister(PLEGRelistInterval)
})
}

Expand Down
14 changes: 14 additions & 0 deletions pkg/kubelet/pleg/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

"github.com/golang/glog"
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/metrics"
"k8s.io/kubernetes/pkg/types"
"k8s.io/kubernetes/pkg/util"
)
Expand Down Expand Up @@ -50,6 +51,8 @@ type GenericPLEG struct {
eventChannel chan *PodLifecycleEvent
// The internal cache for container information.
containers map[string]containerInfo
// Time of the last relisting.
lastRelistTime time.Time
}

type containerInfo struct {
Expand Down Expand Up @@ -101,6 +104,17 @@ func generateEvent(podID types.UID, cid string, oldState, newState kubecontainer
// with the internal pods/containers, and generats events accordingly.
func (g *GenericPLEG) relist() {
glog.V(5).Infof("GenericPLEG: Relisting")
timestamp := time.Now()

if !g.lastRelistTime.IsZero() {
metrics.PLEGRelistInterval.Observe(metrics.SinceInMicroseconds(g.lastRelistTime))
}
defer func() {
// Update the relist time.
g.lastRelistTime = timestamp
metrics.PLEGRelistLatency.Observe(metrics.SinceInMicroseconds(timestamp))
}()

// Get all the pods.
pods, err := g.runtime.GetPods(true)
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions pkg/metrics/kubelet_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ var KnownKubeletMetrics = map[string][]string{
"kubelet_generate_pod_status_latency_microseconds": {"quantile"},
"kubelet_generate_pod_status_latency_microseconds_count": {},
"kubelet_generate_pod_status_latency_microseconds_sum": {},
"kubelet_pleg_relist_latency_microseconds": {"quantile"},
"kubelet_pleg_relist_latency_microseconds_sum": {},
"kubelet_pleg_relist_latency_microseconds_count": {},
"kubelet_pleg_relist_interval_microseconds": {"quantile"},
"kubelet_pleg_relist_interval_microseconds_sum": {},
"kubelet_pleg_relist_interval_microseconds_count": {},
"kubelet_pod_start_latency_microseconds": {"quantile"},
"kubelet_pod_start_latency_microseconds_count": {},
"kubelet_pod_start_latency_microseconds_sum": {},
Expand Down