diff --git a/plugins/inputs/vsphere/README.md b/plugins/inputs/vsphere/README.md index c7d438a9c9285..cff9df965dd69 100644 --- a/plugins/inputs/vsphere/README.md +++ b/plugins/inputs/vsphere/README.md @@ -566,6 +566,7 @@ For a detailed list of commonly available metrics, please refer to * esxhost (name of ESXi host) * guest (guest operating system id) * resource pool (name of resource pool) + * memorySizeMB (configured RAM in MB) * cpu stats for Host and VM * cpu (cpu core - not all CPU fields will have this tag) * datastore stats for Host and VM diff --git a/plugins/inputs/vsphere/endpoint.go b/plugins/inputs/vsphere/endpoint.go index 4694fc9d933d6..41a44008eade0 100644 --- a/plugins/inputs/vsphere/endpoint.go +++ b/plugins/inputs/vsphere/endpoint.go @@ -100,6 +100,7 @@ type objectRef struct { ref types.ManagedObjectReference parentRef *types.ManagedObjectReference //Pointer because it must be nillable guest string + memorySizeMB int32 dcname string rpname string customValues map[string]string @@ -845,6 +846,7 @@ func getVMs(ctx context.Context, e *Endpoint, resourceFilter *ResourceFilter) (o } uuid = r.Config.Uuid } + cvs := make(map[string]string) if e.customAttrEnabled { for _, cv := range r.Summary.CustomValue { @@ -867,6 +869,7 @@ func getVMs(ctx context.Context, e *Endpoint, resourceFilter *ResourceFilter) (o ref: r.ExtensibleManagedObject.Reference(), parentRef: r.Runtime.Host, guest: guest, + memorySizeMB: r.Summary.Config.MemorySizeMB, altID: uuid, rpname: rpname, customValues: e.loadCustomAttributes(r.ManagedEntity), @@ -1338,6 +1341,9 @@ func (e *Endpoint) populateTags(objectRef *objectRef, resourceType string, resou if resourceType == "vm" && objectRef.rpname != "" { t["rpname"] = objectRef.rpname } + if resourceType == "vm" && objectRef.memorySizeMB != 0 { + t["memorySizeMB"] = strconv.Itoa(int(objectRef.memorySizeMB)) + } // Map parent reference parent, found := e.getParent(objectRef, resource) diff --git a/plugins/inputs/vsphere/finder.go b/plugins/inputs/vsphere/finder.go index 9b9254205d199..8d58653c1c1d7 100644 --- a/plugins/inputs/vsphere/finder.go +++ b/plugins/inputs/vsphere/finder.go @@ -258,8 +258,8 @@ func init() { "HostSystem": {"parent", "summary.customValue", "customValue"}, "ResourcePool": {"parent", "customValue"}, "VirtualMachine": {"runtime.host", "config.guestId", "config.uuid", "runtime.powerState", - "summary.customValue", "guest.guestId", "guest.net", "guest.hostName", "resourcePool", - "customValue"}, + "summary.customValue", "summary.config.memorySizeMB", "guest.guestId", "guest.net", "guest.hostName", + "resourcePool", "customValue"}, "Datastore": {"parent", "info", "customValue"}, "ClusterComputeResource": {"parent", "customValue"}, "Datacenter": {"parent", "customValue"},