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

feat(inputs.vsphere): Add VM memory configuration #11591

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions plugins/inputs/vsphere/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions plugins/inputs/vsphere/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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),
Expand Down Expand Up @@ -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))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the original concern was that memory size, a numeric value, should not be a tag. Happy to see this as a field, but setting as a tag would cause a lot of issues with cardinality.


// Map parent reference
parent, found := e.getParent(objectRef, resource)
Expand Down
4 changes: 2 additions & 2 deletions plugins/inputs/vsphere/finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
Loading