Merge pull request #2034 from usabilla/mapped_file
Adds mapped_file metric
This commit is contained in:
commit
2fa6c624a2
@ -503,10 +503,12 @@ func setMemoryStats(s *cgroups.Stats, ret *info.ContainerStats) {
|
||||
ret.Memory.Cache = s.MemoryStats.Stats["total_cache"]
|
||||
ret.Memory.RSS = s.MemoryStats.Stats["total_rss"]
|
||||
ret.Memory.Swap = s.MemoryStats.Stats["total_swap"]
|
||||
ret.Memory.MappedFile = s.MemoryStats.Stats["total_mapped_file"]
|
||||
} else {
|
||||
ret.Memory.Cache = s.MemoryStats.Stats["cache"]
|
||||
ret.Memory.RSS = s.MemoryStats.Stats["rss"]
|
||||
ret.Memory.Swap = s.MemoryStats.Stats["swap"]
|
||||
ret.Memory.MappedFile = s.MemoryStats.Stats["mapped_file"]
|
||||
}
|
||||
if v, ok := s.MemoryStats.Stats["pgfault"]; ok {
|
||||
ret.Memory.ContainerData.Pgfault = v
|
||||
|
@ -53,6 +53,7 @@ Metric name | Type | Description | Unit (where applicable)
|
||||
`container_memory_max_usage_bytes` | Gauge | Maximum memory usage recorded | bytes
|
||||
`container_memory_rss` | Gauge | Size of RSS | bytes
|
||||
`container_memory_swap` | Gauge | Container swap usage | bytes
|
||||
`container_memory_mapped_file` | Gauge | Size of memory mapped files | bytes
|
||||
`container_memory_usage_bytes` | Gauge | Current memory usage, including all memory regardless of when it was accessed | bytes
|
||||
`container_memory_working_set_bytes` | Gauge | Current working set | bytes
|
||||
`container_network_receive_bytes_total` | Counter | Cumulative count of bytes received | bytes
|
||||
|
@ -358,6 +358,9 @@ type MemoryStats struct {
|
||||
// Units: Bytes.
|
||||
Swap uint64 `json:"swap"`
|
||||
|
||||
// The amount of memory used for mapped files (includes tmpfs/shmem)
|
||||
MappedFile uint64 `json:"mapped_file"`
|
||||
|
||||
// The amount of working set memory, this includes recently accessed memory,
|
||||
// dirty memory, and kernel memory. Working set is <= "usage".
|
||||
// Units: Bytes.
|
||||
|
@ -46,6 +46,7 @@ func GenerateRandomStats(numStats, numCores int, duration time.Duration) []*info
|
||||
stats.Memory.Usage = uint64(rand.Int63n(4096))
|
||||
stats.Memory.Cache = uint64(rand.Int63n(4096))
|
||||
stats.Memory.RSS = uint64(rand.Int63n(4096))
|
||||
stats.Memory.MappedFile = uint64(rand.Int63n(4096))
|
||||
ret[i] = stats
|
||||
}
|
||||
return ret
|
||||
|
@ -289,6 +289,13 @@ func NewPrometheusCollector(i infoProvider, f ContainerLabelsFunc, includedMetri
|
||||
getValues: func(s *info.ContainerStats) metricValues {
|
||||
return metricValues{{value: float64(s.Memory.RSS)}}
|
||||
},
|
||||
}, {
|
||||
name: "container_memory_mapped_file",
|
||||
help: "Size of memory mapped files in bytes.",
|
||||
valueType: prometheus.GaugeValue,
|
||||
getValues: func(s *info.ContainerStats) metricValues {
|
||||
return metricValues{{value: float64(s.Memory.MappedFile)}}
|
||||
},
|
||||
}, {
|
||||
name: "container_memory_swap",
|
||||
help: "Container swap usage in bytes.",
|
||||
|
@ -126,6 +126,7 @@ func (p testSubcontainersInfoProvider) SubcontainersInfo(string, *info.Container
|
||||
},
|
||||
Cache: 14,
|
||||
RSS: 15,
|
||||
MappedFile: 16,
|
||||
Swap: 8192,
|
||||
},
|
||||
Network: info.NetworkStats{
|
||||
|
3
metrics/testdata/prometheus_metrics
vendored
3
metrics/testdata/prometheus_metrics
vendored
@ -121,6 +121,9 @@ container_memory_failures_total{container_env_foo_env="prod",container_label_foo
|
||||
container_memory_failures_total{container_env_foo_env="prod",container_label_foo_label="bar",id="testcontainer",image="test",name="testcontaineralias",scope="container",type="pgmajfault",zone_name="hello"} 11
|
||||
container_memory_failures_total{container_env_foo_env="prod",container_label_foo_label="bar",id="testcontainer",image="test",name="testcontaineralias",scope="hierarchy",type="pgfault",zone_name="hello"} 12
|
||||
container_memory_failures_total{container_env_foo_env="prod",container_label_foo_label="bar",id="testcontainer",image="test",name="testcontaineralias",scope="hierarchy",type="pgmajfault",zone_name="hello"} 13
|
||||
# HELP container_memory_mapped_file Size of memory mapped files in bytes.
|
||||
# TYPE container_memory_mapped_file gauge
|
||||
container_memory_mapped_file{container_env_foo_env="prod",container_label_foo_label="bar",id="testcontainer",image="test",name="testcontaineralias",zone_name="hello"} 16
|
||||
# HELP container_memory_max_usage_bytes Maximum memory usage recorded in bytes
|
||||
# TYPE container_memory_max_usage_bytes gauge
|
||||
container_memory_max_usage_bytes{container_env_foo_env="prod",container_label_foo_label="bar",id="testcontainer",image="test",name="testcontaineralias",zone_name="hello"} 8
|
||||
|
@ -43,6 +43,8 @@ const (
|
||||
colMemoryWorkingSet string = "memory_working_set"
|
||||
// Resident set size
|
||||
colMemoryRSS string = "memory_rss"
|
||||
// Mapped files size
|
||||
colMemoryMappedFile string = "memory_mapped_file"
|
||||
// Cumulative count of bytes received.
|
||||
colRxBytes string = "rx_bytes"
|
||||
// Cumulative count of receive errors encountered.
|
||||
@ -85,6 +87,9 @@ func (self *statsdStorage) containerStatsToValues(
|
||||
// Resident set size
|
||||
series[colMemoryRSS] = stats.Memory.RSS
|
||||
|
||||
// Mapped files size
|
||||
series[colMemoryMappedFile] = stats.Memory.MappedFile
|
||||
|
||||
// Network stats.
|
||||
series[colRxBytes] = stats.Network.RxBytes
|
||||
series[colRxErrors] = stats.Network.RxErrors
|
||||
|
Loading…
Reference in New Issue
Block a user