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

Add Vsphere module with metrics. WIP #4028

Merged
merged 33 commits into from
May 4, 2017
Merged

Add Vsphere module with metrics. WIP #4028

merged 33 commits into from
May 4, 2017

Conversation

amandahla
Copy link

@amandahla amandahla commented Apr 17, 2017

Hi. This is a initial version for Vsphere module, just collecting datastore usage metrics.
We used Govmomi library and the example in:
https://github.com/vmware/govmomi/blob/master/examples/datastores/main.go

TODO:

  • Collect cpu and memory of each Host.
  • Collect cpu and memory of each VM.
  • Unity tests.

@elasticmachine
Copy link
Collaborator

Jenkins standing by to test this. If you aren't a maintainer, you can ignore this comment. Someone with commit access, please review this and clear it for Jenkins to run.

1 similar comment
@elasticmachine
Copy link
Collaborator

Jenkins standing by to test this. If you aren't a maintainer, you can ignore this comment. Someone with commit access, please review this and clear it for Jenkins to run.

@amandahla amandahla changed the title Add Vsphere module with Datastore_usage metric. Add Vsphere module with Datastore_usage metric. WIP Apr 17, 2017
@ruflin ruflin added Metricbeat Metricbeat review needs tests in progress Pull request is currently in progress. labels Apr 18, 2017
@ruflin
Copy link
Member

ruflin commented Apr 18, 2017

@amandahla Thanks a lot for kicking off this contribution. Let me know when we should do a first review. Be aware that we recently switched to govendor to handle the dependencies and we try to keep the dependencies for a module in a vendor directory local to the module.

@amandahla amandahla changed the title Add Vsphere module with Datastore_usage metric. WIP Add Vsphere module with metrics. WIP Apr 18, 2017
@andrewkroh
Copy link
Member

Looks like you are off to a good start. So would Metricbeat run directly on each ESXi host or would it run on the vCenter host?

@amandahla
Copy link
Author

Hello @andrewkroh, actually Metricbeat can collect from any Vmware SDK URL (ESXi/VCenter).
But...I would not recommend to run inside those hosts because installing 3rd party software is not supported by the vendor.

@amandahla
Copy link
Author

Hi @ruflin . I made some modifications and I think that now it's ready for a first review. Thanks!

Copy link
Member

@ruflin ruflin left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the addition. I left a few minor comments.

@@ -0,0 +1,10 @@
#- module: vsphere
Copy link
Member

Choose a reason for hiding this comment

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

Be aware that we change the logic here a bit in #4049

Copy link
Author

Choose a reason for hiding this comment

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

@@ -85,6 +85,10 @@ import (
_ "github.com/elastic/beats/metricbeat/module/system/network"
_ "github.com/elastic/beats/metricbeat/module/system/process"
_ "github.com/elastic/beats/metricbeat/module/system/socket"
_ "github.com/elastic/beats/metricbeat/module/vsphere"
_ "github.com/elastic/beats/metricbeat/module/vsphere/datastore_usage"
Copy link
Member

Choose a reason for hiding this comment

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

Do we need the appendix usage for the metricset names? Are there potential other metricsets for datastore for example?

Copy link
Author

Choose a reason for hiding this comment

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

Actually thinking about it...No, we don't need. I removed now.

@@ -0,0 +1,4 @@
== vsphere Module

This is the vsphere Module.
Copy link
Member

Choose a reason for hiding this comment

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

Could you add some more details here, for example link to vSphere (installation) page or docs? Also did you test with a specific version?

Copy link
Author

Choose a reason for hiding this comment

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

},
"vsphere":{
"datastore_usage":{
"example": "datastore_usage"
Copy link
Member

Choose a reason for hiding this comment

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

Needs update with an example event. You can run go test -tags=integration github.com/elastic/beats/metricbeat/module/vsphere/... -data when your environment is running.

Copy link
Author

Choose a reason for hiding this comment

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

type: long
description: >
Used percent of the datastore

Copy link
Member

Choose a reason for hiding this comment

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

You can add format: percent here for Kibana.

Copy link
Author

Choose a reason for hiding this comment

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

"testing"
)

func TestFetchEventContents(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Test missing

@@ -0,0 +1,97 @@
{
"comment": "",
"ignore": "test",
Copy link
Member

Choose a reason for hiding this comment

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

I would expect here "ignore": "test github.com/elastic/beats" as otherwise if you remove the libs from the vendor dir and then run govendor sync it will also load libbeat etc. into it.

Copy link
Author

Choose a reason for hiding this comment

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

},
"vsphere":{
"virtualmachine_usage":{
"example": "virtualmachine_usage"
Copy link
Member

Choose a reason for hiding this comment

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

needs update

"memory": common.MapStr{
"used": common.MapStr{
"guest": common.MapStr{
"bytes": vm.Summary.QuickStats.GuestMemoryUsage * 1024,
Copy link
Member

Choose a reason for hiding this comment

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

What are the raw values of all these * 1024?

Copy link
Author

Choose a reason for hiding this comment

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

vm.Summary.QuickStats.GuestMemoryUsage, vm.Summary.QuickStats.HostMemoryUsage and vm.Summary.Config.MemorySizeMB are values in MB so I had to multiply all for 1024 to get bytes values.

Copy link
Member

Choose a reason for hiding this comment

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

1024*1024?

Copy link
Author

Choose a reason for hiding this comment

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

😳

)

func TestFetchEventContents(t *testing.T) {
assert.EqualValues(t, 1, 1)
Copy link
Member

Choose a reason for hiding this comment

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

Needs update

@amandahla
Copy link
Author

amandahla commented May 3, 2017

Hi @ruflin . I've made all the changes that you asked but now I don't know why the Travis build is failing. It's something related to filebeat testsuit in OSX nothing regardless this module. :-)

@ruflin ruflin removed the in progress Pull request is currently in progress. label May 3, 2017
@ruflin
Copy link
Member

ruflin commented May 3, 2017

@amandahla Great. I restarted the build manually and will have a look at the PR soon.

Copy link
Member

@ruflin ruflin left a comment

Choose a reason for hiding this comment

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

LGTM

Two requests which can also happen after merging:

  • Create the data.json with some example events
  • Add Dashboards

},
"vsphere":{
"datastore":{
"example": "datastore"
Copy link
Member

Choose a reason for hiding this comment

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

Would be nice to have here a full example data set. This can happen in a follow up PR.

},
"vsphere":{
"host":{
"example": "host"
Copy link
Member

Choose a reason for hiding this comment

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

Example doc here would be nice.

@ruflin
Copy link
Member

ruflin commented May 3, 2017

jenkins, test it

@ruflin ruflin merged commit f4e38b9 into elastic:master May 4, 2017
@ruflin
Copy link
Member

ruflin commented May 4, 2017

@amandahla Thanks a lot for the contribution.

@ruflin ruflin removed the needs tests label May 4, 2017
@amandahla
Copy link
Author

Thanks! :-)

@ruflin
Copy link
Member

ruflin commented May 4, 2017

@amandahla If you have some time to open a new PR with the data.json that would be great.

@amandahla
Copy link
Author

@ruflin Sure, I'm already working on it! 👍

@rikatz
Copy link
Contributor

rikatz commented May 4, 2017

🎉 🎉 🎉 🎉

@petericebear
Copy link

I get a Bad request using this module. I am using the same credentials that I am using with Chef Knife Vsphere module.
Any idea's how that is possible or how to debug the request?

@amandahla
Copy link
Author

@petericebear I saw that Knife uses "knife[:vsphere_host] = "vcenter-hostname""
Did you set hosts like "hosts: ["https://localhost/sdk"]" ?

@petericebear
Copy link

I now have this:

metricsets: ["virtualmachine"]
enabled: true
period: 10s
hosts: ["https://hostnameweblocation.com/"]

with insecure to true

@petericebear
Copy link

And with this setting:
metricsets: ["datastore, host, virtualmachine"]

I get the error:
Exiting: 1 error: metricset 'vsphere/datastore, host, virtualmachine' is not registered, metricset not found

@amandahla
Copy link
Author

Please try
metricsets: ["datastore", "host", "virtualmachine"]
hosts: ["https://hostnameweblocation.com/sdk"]

@petericebear
Copy link

petericebear commented Aug 8, 2017

- module: vsphere
  metricsets: 
    - datastore
    - host
    - virtualmachine
  enabled: true
  period: 10s
  hosts: ["https://domain.org/sdk"]

  username: "XXX"
  password: "XXX"
  
  insecure: true
  get_custom_fields: false

This was the fix :) Thank you for your swift reply

@amandahla
Copy link
Author

So it worked fine now? Did you just need to put get_custom_fields: false?

@petericebear
Copy link

petericebear commented Aug 8, 2017

Only some bytes in the data are negative. But I think I saw a PR for that?
It is this field: vsphere.virtualmachine.memory.total.guest.bytes
that gives bogus numbers.

I added the /sdk to the url, and I changed the metricsets from:
metricsets: ["datastore", "host", "virtualmachine"]

to:

metricsets: 
    - datastore
    - host
    - virtualmachine

Running on OSX (Latest)

@amandahla
Copy link
Author

Yes, this PR solved that
#4462

@petericebear
Copy link

Are you working on the functionality of disk usage and network usage for virtual machines?
With that information we can realtime monitor everything from the server.

@petericebear
Copy link

petericebear commented Aug 17, 2017

I found out that Performance Manager can retrieve stats by level and key like cpu.usage.average.
Like this example:
https://gist.github.com/toobulkeh/6124975

If this a possibility for a beats module for given the keys to retrieve? That way we can have more data out of vSphere into Elasticsearch. I saw that the data changed with this module is changed every 60 seconds so the 10second interval is to low as default.

If you have another solution for using the Performance Manager for making similar graphs in Kibana as in vCenter I would be really grateful. If you need more information. Please contact me, very happy to help

@amandahla
Copy link
Author

@petericebear Hi, thanks for your suggestion. I tried to use this but I couldn't find a way to work (https://github.com/vmware/govmomi/blob/master/performance/manager.go). I found it too difficult since we need for now just a few things. And I'm not sure, but I think that using Performance Manager we don't collect realtime metrics, just historical.

@rezaa1
Copy link

rezaa1 commented Sep 20, 2017

Hi,
Thanks for great work.

I installed vspher beat from elastic 6 beta. But I can't see any sample dashboard for this beat. Dose it come with any dashboard?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants