Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

metrics: added mapped_file metric #11500

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/11500.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
metrics: added nomad.client.allocs.memory.mapped_file metric
```
1 change: 1 addition & 0 deletions client/allocrunner/taskrunner/task_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,7 @@ func (tr *TaskRunner) setGaugeForMemory(ru *cstructs.TaskResourceUsage) {
publishMetric(ms.RSS, "rss", "RSS")
publishMetric(ms.Cache, "cache", "Cache")
publishMetric(ms.Swap, "swap", "Swap")
publishMetric(ms.MappedFile, "mapped_file", "MappedFile")
deblasis marked this conversation as resolved.
Show resolved Hide resolved
publishMetric(ms.Usage, "usage", "Usage")
publishMetric(ms.MaxUsage, "max_usage", "Max Usage")
publishMetric(ms.KernelUsage, "kernel_usage", "Kernel Usage")
Expand Down
2 changes: 2 additions & 0 deletions client/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ type MemoryStats struct {
RSS uint64
Cache uint64
Swap uint64
MappedFile uint64
Usage uint64
MaxUsage uint64
KernelUsage uint64
Expand All @@ -223,6 +224,7 @@ func (ms *MemoryStats) Add(other *MemoryStats) {
ms.RSS += other.RSS
ms.Cache += other.Cache
ms.Swap += other.Swap
ms.MappedFile += other.MappedFile
ms.Usage += other.Usage
ms.MaxUsage += other.MaxUsage
ms.KernelUsage += other.KernelUsage
Expand Down
2 changes: 2 additions & 0 deletions drivers/docker/stats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func TestDriver_DockerStatsCollector(t *testing.T) {
stats.MemoryStats.Stats.Rss = 6537216
stats.MemoryStats.Stats.Cache = 1234
stats.MemoryStats.Stats.Swap = 0
stats.MemoryStats.Stats.MappedFile = 1024
stats.MemoryStats.Usage = 5651904
stats.MemoryStats.MaxUsage = 6651904
stats.MemoryStats.Commit = 123231
Expand All @@ -47,6 +48,7 @@ func TestDriver_DockerStatsCollector(t *testing.T) {
require.Equal(stats.MemoryStats.Stats.Rss, ru.ResourceUsage.MemoryStats.RSS)
require.Equal(stats.MemoryStats.Stats.Cache, ru.ResourceUsage.MemoryStats.Cache)
require.Equal(stats.MemoryStats.Stats.Swap, ru.ResourceUsage.MemoryStats.Swap)
require.Equal(stats.MemoryStats.Stats.MappedFile, ru.ResourceUsage.MemoryStats.MappedFile)
require.Equal(stats.MemoryStats.Usage, ru.ResourceUsage.MemoryStats.Usage)
require.Equal(stats.MemoryStats.MaxUsage, ru.ResourceUsage.MemoryStats.MaxUsage)
require.Equal(stats.CPUStats.ThrottlingData.ThrottledPeriods, ru.ResourceUsage.CpuStats.ThrottledPeriods)
Expand Down
13 changes: 7 additions & 6 deletions drivers/docker/util/stats_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ func DockerStatsToTaskResourceUsage(s *docker.Stats) *cstructs.TaskResourceUsage
}

ms := &cstructs.MemoryStats{
RSS: s.MemoryStats.Stats.Rss,
Cache: s.MemoryStats.Stats.Cache,
Swap: s.MemoryStats.Stats.Swap,
Usage: s.MemoryStats.Usage,
MaxUsage: s.MemoryStats.MaxUsage,
Measured: measuredMems,
RSS: s.MemoryStats.Stats.Rss,
Cache: s.MemoryStats.Stats.Cache,
Swap: s.MemoryStats.Stats.Swap,
MappedFile: s.MemoryStats.Stats.MappedFile,
Usage: s.MemoryStats.Usage,
MaxUsage: s.MemoryStats.MaxUsage,
Measured: measuredMems,
}

cs := &cstructs.CpuStats{
Expand Down
2 changes: 2 additions & 0 deletions drivers/shared/executor/executor_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,12 @@ func (l *LibcontainerExecutor) handleStats(ch chan *cstructs.TaskResourceUsage,
maxUsage := stats.MemoryStats.Usage.MaxUsage
rss := stats.MemoryStats.Stats["rss"]
cache := stats.MemoryStats.Stats["cache"]
mapped_file := stats.MemoryStats.Stats["mapped_file"]
ms := &cstructs.MemoryStats{
RSS: rss,
Cache: cache,
Swap: swap.Usage,
MappedFile: mapped_file,
Usage: stats.MemoryStats.Usage.Usage,
MaxUsage: maxUsage,
KernelUsage: stats.MemoryStats.KernelUsage.Usage,
Expand Down