Skip to content

Commit

Permalink
Adding ContainersPerPodCount metric.
Browse files Browse the repository at this point in the history
This will let us know the composition of pods in clusters.
  • Loading branch information
vmarmol committed Feb 27, 2015
1 parent 0141561 commit 556acc7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions pkg/kubelet/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,11 @@ func (kl *Kubelet) SyncPods(pods []api.BoundPod, podSyncTypes map[types.UID]metr
kl.podWorkers.UpdatePod(pod, func() {
metrics.SyncPodLatency.WithLabelValues(podSyncTypes[pod.UID].String()).Observe(metrics.SinceInMicroseconds(start))
})

// Note the number of containers for new pods.
if val, ok := podSyncTypes[pod.UID]; ok && (val == metrics.SyncPodCreate) {
metrics.ContainersPerPodCount.Observe(float64(len(pod.Spec.Containers)))
}
}

// Stop the workers for no-longer existing pods.
Expand Down
10 changes: 8 additions & 2 deletions pkg/kubelet/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ var (
Help: "Image pull latency in microseconds.",
},
)
// TODO(vmarmol): Break down by number of containers in pod?
ContainersPerPodCount = prometheus.NewSummary(
prometheus.SummaryOpts{
Subsystem: kubeletSubsystem,
Name: "containers_per_pod_count",
Help: "The number of containers per pod.",
},
)
SyncPodLatency = prometheus.NewSummaryVec(
prometheus.SummaryOpts{
Subsystem: kubeletSubsystem,
Expand All @@ -52,7 +58,6 @@ var (
Help: "Latency in microseconds to sync all pods.",
},
)
// TODO(vmarmol): Containers per pod
DockerOperationsLatency = prometheus.NewSummaryVec(
prometheus.SummaryOpts{
Subsystem: kubeletSubsystem,
Expand All @@ -73,6 +78,7 @@ func Register(containerCache dockertools.DockerCache) {
prometheus.MustRegister(SyncPodLatency)
prometheus.MustRegister(DockerOperationsLatency)
prometheus.MustRegister(SyncPodsLatency)
prometheus.MustRegister(ContainersPerPodCount)
prometheus.MustRegister(newPodAndContainerCollector(containerCache))
})
}
Expand Down

0 comments on commit 556acc7

Please sign in to comment.