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

[receiver/vcenter] Adds vCenter VM CPU readiness metric #33608

Merged

Conversation

BominRahmani
Copy link
Contributor

Description:

This PR adds the vcenter.vm.cpu.readiness metric.
More information on this metric can be found here.
Link to tracking Issue: #33607

Testing:
The metric was scraped from a test vCenter environment, and golden test files were updated to reflect the addition of the metric.

Documentation:
Documentation was updated according to the metadata.yaml

@BominRahmani BominRahmani force-pushed the feat/add-vcenter-vm-cpu-metric branch 2 times, most recently from 6c99f2f to f4a517e Compare June 18, 2024 03:09
Copy link
Contributor

@StefanKurek StefanKurek left a comment

Choose a reason for hiding this comment

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

@BominRahmani Overall looks OK. Have a few questions though. Also think it needs an integration test update.

receiver/vcenterreceiver/metadata.yaml Outdated Show resolved Hide resolved
receiver/vcenterreceiver/testdata/metrics/expected.yaml Outdated Show resolved Hide resolved
receiver/vcenterreceiver/testdata/metrics/expected.yaml Outdated Show resolved Hide resolved
receiver/vcenterreceiver/metrics.go Outdated Show resolved Hide resolved
@BominRahmani BominRahmani force-pushed the feat/add-vcenter-vm-cpu-metric branch from 9a14bb3 to 2d172a6 Compare June 18, 2024 19:18

// OverallCpuReadiness is only available in vSphere API 7.0
// https://vdc-repo.vmware.com/vmwb-repository/dcr-public/d1902b0e-d479-46bf-8ac9-cee0e31e8ec0/07ce8dbd-db48-4261-9b8f-c6d3ad8ba472/vim.vm.Summary.QuickStats.html
vsphereAPIVersion, err := version.NewVersion(v.scrapeData.apiVersion)
Copy link
Contributor

@StefanKurek StefanKurek Jun 18, 2024

Choose a reason for hiding this comment

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

I went back and forth on whether I was going to comment more on this or just leave it be.

It seems like this logic could be moved to a new function (or maybe even to the client as a helper function). The client could be reworked to have a private method like "refreshVsphereAPIVersion" which stores its own version. We could make sure we call this once a collection (or on client initialization). Then we could have another method vsphereAPIVersionMeetsMin(minVsphereAPIVersion string) bool that would be used here where you just pass in "7.0.0". It could do all this logic (making use of the stored version (possibly calling refresh if it's empty) and then return a true/false for the conditional for lines 158/159. This would be reusable for other cases too.

Ultimately I think I'm fine with it as is, just thinking that it feels a little out of place here and would likely be better placed elsewhere. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is probably a good idea, there may be more of these metrics that require a check on the API in the future. I'll look into changing it up!

Copy link
Contributor

Choose a reason for hiding this comment

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

That will be a great add-on, Readiness is the most important CPU metric for a VM. I had started to worked on a PR to add it, glad I checked here again!

For the documentation you refer to, maybe we can use the one hosted by Broadcom as it will be updated there: https://developer.broadcom.com/xapis/virtual-infrastructure-json-api/latest/data-structures/VirtualMachineQuickStats/

The API version requirement (7.0.0) for overallCpuReadiness is not in it, not sure why, as there are other recommendations. Same for grantedMemory.

The others metrics that required a recent API version are not used in the receiver yet:

  • activeMemory
  • memoryTierStats

But we could probably add them at some point, especially grantedMemory, so good idea @StefanKurek for the private method.

I can check the other requirements for Host, Cluster and Datastore.

Copy link
Contributor

Choose a reason for hiding this comment

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

@jlg-io That JSON API is a totally different (and would require major changes to the vcenterreceiver) from how we're currently collecting. In addition, it looks like it's only been available since vCenter 8.0+. I do agree that a note in the README would be a good add.

Copy link
Contributor

@jlg-io jlg-io Jun 19, 2024

Choose a reason for hiding this comment

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

@StefanKurek, my bad! I guess the right one is there: https://dp-downloads.broadcom.com/api-content/apis/API_VMA_001/8.0U2/html/vim.vm.Summary.QuickStats.html

It has been updated more recently than the one on VMware website, so I guess it will be the reference for the future

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I'll add in a section in the readme and also update the link in the comments.

Copy link
Contributor

@jlg-io jlg-io left a comment

Choose a reason for hiding this comment

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

Great work!

Maybe we could update vcenterreceiver/README.md to either drop support for 6.7 or add a comment that overallCpuReadiness won't work with this version?


// OverallCpuReadiness is only available in vSphere API 7.0
// https://vdc-repo.vmware.com/vmwb-repository/dcr-public/d1902b0e-d479-46bf-8ac9-cee0e31e8ec0/07ce8dbd-db48-4261-9b8f-c6d3ad8ba472/vim.vm.Summary.QuickStats.html
vsphereAPIVersion, err := version.NewVersion(v.scrapeData.apiVersion)
Copy link
Contributor

Choose a reason for hiding this comment

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

That will be a great add-on, Readiness is the most important CPU metric for a VM. I had started to worked on a PR to add it, glad I checked here again!

For the documentation you refer to, maybe we can use the one hosted by Broadcom as it will be updated there: https://developer.broadcom.com/xapis/virtual-infrastructure-json-api/latest/data-structures/VirtualMachineQuickStats/

The API version requirement (7.0.0) for overallCpuReadiness is not in it, not sure why, as there are other recommendations. Same for grantedMemory.

The others metrics that required a recent API version are not used in the receiver yet:

  • activeMemory
  • memoryTierStats

But we could probably add them at some point, especially grantedMemory, so good idea @StefanKurek for the private method.

I can check the other requirements for Host, Cluster and Datastore.

@BominRahmani BominRahmani force-pushed the feat/add-vcenter-vm-cpu-metric branch from c65c735 to 6de60f2 Compare June 19, 2024 20:50
receiver/vcenterreceiver/README.md Outdated Show resolved Hide resolved
receiver/vcenterreceiver/metrics.go Outdated Show resolved Hide resolved
receiver/vcenterreceiver/metadata.yaml Outdated Show resolved Hide resolved
receiver/vcenterreceiver/testdata/metrics/expected.yaml Outdated Show resolved Hide resolved
@BominRahmani BominRahmani force-pushed the feat/add-vcenter-vm-cpu-metric branch from 55d2863 to c742018 Compare June 20, 2024 14:43
@BominRahmani BominRahmani force-pushed the feat/add-vcenter-vm-cpu-metric branch from c7ca22d to 3430d83 Compare June 20, 2024 21:01
Copy link
Contributor

@StefanKurek StefanKurek left a comment

Choose a reason for hiding this comment

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

Looks good enough to move out of Draft form. Thanks!

@BominRahmani BominRahmani marked this pull request as ready for review June 21, 2024 01:59
receiver/vcenterreceiver/README.md Outdated Show resolved Hide resolved
@@ -74,6 +76,7 @@ func (vc *vcenterClient) EnsureConnection(ctx context.Context) error {
vc.finder = find.NewFinder(vc.vimDriver)
vc.pm = performance.NewManager(vc.vimDriver)
vc.vm = view.NewManager(vc.vimDriver)
vc.apiVersion = vc.getVsphereAPIVersion()
Copy link
Member

Choose a reason for hiding this comment

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

If we drop support for 6.7 we don't need this check. Perhaps there is a reasonable way to fail gracefully if the server does not support the new metric?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we can just drop support for 6.7 in this case. The problem with this metric is it doesn't really fail, rather it returns 0 if the server doesn't support the metric, but 0 in of itself is a valid value.

Copy link
Contributor

Choose a reason for hiding this comment

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

As 6.7 is "End of General Support" since October 15, 2022 (https://core.vmware.com/blog/reminder-vsphere-6567-end-general-support), it would make sense to drop the support here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@djaglowski To drop support for a version do we need to make a new pr / add warnings anywhere? or are we allowed to just remove it from the readme.

Copy link
Member

Choose a reason for hiding this comment

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

@BominRahmani, a separate PR would be ideal but I think it's ok to do here as long as there's a separate changelog entry for it. You can just add a second changelog yaml file and note it there.

@BominRahmani BominRahmani force-pushed the feat/add-vcenter-vm-cpu-metric branch from c39b81d to d77a71e Compare July 1, 2024 13:41
@djaglowski djaglowski merged commit 0e9dde7 into open-telemetry:main Jul 1, 2024
154 checks passed
@github-actions github-actions bot added this to the next release milestone Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants