Subtract page cache from container memory usage

So that Scope numbers match Docker numbers.
This commit is contained in:
Bryan Boreham
2018-11-21 16:07:57 +00:00
parent 476ef275e6
commit fb9c9e0140
+4 -1
View File
@@ -336,7 +336,10 @@ func (c *container) memoryUsageMetric(stats []docker.Stats) report.Metric {
samples := make([]report.Sample, len(stats))
for i, s := range stats {
samples[i].Timestamp = s.Read
samples[i].Value = float64(s.MemoryStats.Usage)
// This code adapted from
// https://github.com/docker/cli/blob/5931fb4276be0afdd6e5ed338d1b2b4b9b5ec8e5/cli/command/container/stats_helpers.go
// so that Scope numbers match Docker numbers. Page cache is intentionally excluded.
samples[i].Value = float64(s.MemoryStats.Usage - s.MemoryStats.Stats.Cache)
if float64(s.MemoryStats.Limit) > max {
max = float64(s.MemoryStats.Limit)
}