From e70b0b7727c0dba82e453a5cbba94f081ce85b39 Mon Sep 17 00:00:00 2001 From: Danish Prakash Date: Wed, 17 Nov 2021 19:04:22 +0530 Subject: [PATCH] client: emit max_memory metric (#11490) --- client/client.go | 1 + nomad/structs/structs.go | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/client/client.go b/client/client.go index f2e8a820e7f0..5bc142406cf8 100644 --- a/client/client.go +++ b/client/client.go @@ -2911,6 +2911,7 @@ func (c *Client) setGaugeForAllocationStats(nodeID string, baseLabels []metrics. // Emit allocated metrics.SetGaugeWithLabels([]string{"client", "allocated", "memory"}, float32(allocated.Flattened.Memory.MemoryMB), baseLabels) + metrics.SetGaugeWithLabels([]string{"client", "allocated", "max_memory"}, float32(allocated.Flattened.Memory.MemoryMaxMB), baseLabels) metrics.SetGaugeWithLabels([]string{"client", "allocated", "disk"}, float32(allocated.Shared.DiskMB), baseLabels) metrics.SetGaugeWithLabels([]string{"client", "allocated", "cpu"}, float32(allocated.Flattened.Cpu.CpuShares), baseLabels) diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index 1c3ed824cdcf..4d4fe19d8e0f 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -9697,7 +9697,7 @@ func (a *Allocation) SetEventDisplayMessages() { // // COMPAT(0.11): Remove in 0.11 func (a *Allocation) ComparableResources() *ComparableResources { - // ALloc already has 0.9+ behavior + // Alloc already has 0.9+ behavior if a.AllocatedResources != nil { return a.AllocatedResources.Comparable() } @@ -9720,7 +9720,8 @@ func (a *Allocation) ComparableResources() *ComparableResources { CpuShares: int64(resources.CPU), }, Memory: AllocatedMemoryResources{ - MemoryMB: int64(resources.MemoryMB), + MemoryMB: int64(resources.MemoryMB), + MemoryMaxMB: int64(resources.MemoryMaxMB), }, Networks: resources.Networks, },