From 1a867bdadd5f9a6991a37538c0a0357f56dc81b8 Mon Sep 17 00:00:00 2001 From: Shimin Guo Date: Wed, 30 Dec 2015 22:54:32 -0800 Subject: [PATCH] expose RSS --- container/libcontainer/helpers.go | 1 + info/v1/container.go | 5 +++++ metrics/prometheus.go | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/container/libcontainer/helpers.go b/container/libcontainer/helpers.go index 19d3adb9..116ae034 100644 --- a/container/libcontainer/helpers.go +++ b/container/libcontainer/helpers.go @@ -378,6 +378,7 @@ func toContainerStats1(s *cgroups.Stats, ret *info.ContainerStats) { func toContainerStats2(s *cgroups.Stats, ret *info.ContainerStats) { ret.Memory.Usage = s.MemoryStats.Usage.Usage ret.Memory.Failcnt = s.MemoryStats.Usage.Failcnt + ret.Memory.RSS = s.MemoryStats.Stats["rss"] if v, ok := s.MemoryStats.Stats["pgfault"]; ok { ret.Memory.ContainerData.Pgfault = v ret.Memory.HierarchicalData.Pgfault = v diff --git a/info/v1/container.go b/info/v1/container.go index 11c03c31..44d5c32f 100644 --- a/info/v1/container.go +++ b/info/v1/container.go @@ -308,6 +308,11 @@ type MemoryStats struct { // Units: Bytes. Usage uint64 `json:"usage"` + // The amount of anonymous and swap cache memory (includes transparent + // hugepages). + // Units: Bytes. + RSS uint64 `json:"rss"` + // The amount of working set memory, this includes recently accessed memory, // dirty memory, and kernel memory. Working set is <= "usage". // Units: Bytes. diff --git a/metrics/prometheus.go b/metrics/prometheus.go index ff4e5d89..410869bc 100644 --- a/metrics/prometheus.go +++ b/metrics/prometheus.go @@ -127,6 +127,13 @@ func NewPrometheusCollector(infoProvider infoProvider, f ContainerNameToLabelsFu } return values }, + }, { + name: "container_memory_rss", + help: "Size of RSS in bytes", + valueType: prometheus.GaugeValue, + getValues: func(s *info.ContainerStats) metricValues { + return metricValues{{value: float64(s.Memory.RSS)}} + }, }, { name: "container_memory_failcnt", help: "Number of memory usage hits limits",