Adding cAdvisor CPU CFS quota metrics
This should make it possible to better monitor container CPU usage vs. the
allocated limits.  The exisitng container_spec_cpu_shares metric only shows
requested amounts and not enforced limits.
@@ -150,6 +150,30 @@ func getContainerMetrics(excludedMetrics map[string]bool) []containerMetric {
return metricValues
},
},
+ {
+ name: "container_cpu_cfs_periods",
+ help: "Total number of elapsed CFS enforcement intervals.",
+ valueType: datapoint.Counter,
+ getValues: func(s *info.ContainerStats) metricValues {
+ return metricValues{{value: datapoint.NewIntValue(int64(s.Cpu.CFS.Periods))}}
+ },
+ },
+ {
+ name: "container_cpu_cfs_throttled_periods",
+ help: "Total number of times tasks in the cgroup have been throttled",
+ valueType: datapoint.Counter,
+ getValues: func(s *info.ContainerStats) metricValues {
+ return metricValues{{value: datapoint.NewIntValue(int64(s.Cpu.CFS.ThrottledPeriods))}}
+ },
+ },
+ {
+ name: "container_cpu_cfs_throttled_time",
+ help: "Total time duration, in nanoseconds, for which tasks in the cgroup have been throttled.",
+ valueType: datapoint.Counter,
+ getValues: func(s *info.ContainerStats) metricValues {
+ return metricValues{{value: datapoint.NewIntValue(int64(s.Cpu.CFS.ThrottledTime))}}
+ },
+ },
{
name: "container_memory_failcnt",
help: "Number of memory usage hits limits",
@@ -490,6 +514,28 @@ func getContainerSpecCPUMetrics(excludedMetrics map[string]bool) []containerSpec
return metricValues{{value: datapoint.NewIntValue(int64(container.Spec.Cpu.Limit))}}
},
},
+ {
+ containerMetric: containerMetric{
+ name: "container_spec_cpu_quota",
+ help: "",
+ valueType: datapoint.Gauge,
+ extraLabels: []string{},
+ },
+ getValues: func(container *info.ContainerInfo) metricValues {
+ return metricValues{{value: datapoint.NewIntValue(int64(container.Spec.Cpu.Quota))}}
+ },
+ },
+ {
+ containerMetric: containerMetric{
+ name: "container_spec_cpu_period",
+ help: "",
+ valueType: datapoint.Gauge,
+ extraLabels: []string{},
+ },
+ getValues: func(container *info.ContainerInfo) metricValues {
+ return metricValues{{value: datapoint.NewIntValue(int64(container.Spec.Cpu.Period))}}
+ },
+ },
}
var index = 0
