Skip to content

Commit

Permalink
[vSphere][network] Add support for new metrics in network metricset (e…
Browse files Browse the repository at this point in the history
…lastic#40559)

* initial commit for network metricset

* mage update

* added changelog entry

* fix changelog

* resolve review comments

* add support for DVPG

* make generic changes
- eventMapping() -> mapEvent()
- MetricSet -> {Host|Network}MetricSet

* resolved review comments

* assetsName -> assetsNames

* make update

* resolved review comment:
bytesMultiplier

* resolve review comments

* resolve review comments

* update changelog entry

* update sample event json

* minor changes

---------

Co-authored-by: Ishleen Kaur <[email protected]>
  • Loading branch information
kush-elastic and ishleenk17 authored Aug 28, 2024
1 parent 7960af6 commit 93ee5ca
Show file tree
Hide file tree
Showing 25 changed files with 664 additions and 67 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- Add new memory/cgroup metrics to Kibana module {pull}37232[37232]
- Add SSL support to mysql module {pull}37997[37997]
- Add SSL support for aerospike module {pull}38126[38126]

- Add new metricset network for the vSphere module. {pull}40559[40559]

*Metricbeat*

Expand Down
99 changes: 99 additions & 0 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -67416,6 +67416,105 @@ type: keyword
Number of virtual machines on the host.


type: long

--

[float]
=== network

Network-related information.



*`vsphere.network.accessible`*::
+
--
Indicates whether at least one host is configured to provide this network.


type: boolean

--

*`vsphere.network.config.status`*::
+
--
Indicates whether the system has detected a configuration issue.


type: keyword

--


*`vsphere.network.host.names`*::
+
--
Names of the hosts connected to this network.


type: keyword

--

*`vsphere.network.host.count`*::
+
--
Number of hosts connected to this network.


type: long

--

*`vsphere.network.name`*::
+
--
Name of the network.


type: keyword

--

*`vsphere.network.status`*::
+
--
General health of the Network.


type: keyword

--

*`vsphere.network.type`*::
+
--
Type of the network (e.g., Network(Standard), DistributedVirtualport).


type: keyword

--


*`vsphere.network.vm.names`*::
+
--
Names of the virtual machines connected to this network.


type: keyword

--

*`vsphere.network.vm.count`*::
+
--
Number of virtual machines connected to this network.


type: long

--
Expand Down
8 changes: 6 additions & 2 deletions metricbeat/docs/modules/vsphere.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This file is generated! See scripts/mage/docs_collector.go

The vSphere module uses the https://github.com/vmware/govmomi[Govmomi] library to collect metrics from any Vmware SDK URL (ESXi/VCenter). This library is built for and tested against ESXi and vCenter 5.5, 6.0 and 6.5.

By default it enables the metricsets `datastore`, `host` and `virtualmachine`.
By default it enables the metricsets `network`, `datastore`, `host` and `virtualmachine`.

[float]
=== Dashboard
Expand All @@ -35,7 +35,7 @@ in <<configuration-metricbeat>>. Here is an example configuration:
metricbeat.modules:
- module: vsphere
enabled: true
metricsets: ["datastore", "host", "virtualmachine"]
metricsets: ["datastore", "host", "virtualmachine", "network"]
# Real-time data collection – An ESXi Server collects data for each performance counter every 20 seconds.
period: 20s
hosts: ["https://localhost/sdk"]
Expand All @@ -57,12 +57,16 @@ The following metricsets are available:

* <<metricbeat-metricset-vsphere-host,host>>

* <<metricbeat-metricset-vsphere-network,network>>

* <<metricbeat-metricset-vsphere-virtualmachine,virtualmachine>>

include::vsphere/datastore.asciidoc[]

include::vsphere/host.asciidoc[]

include::vsphere/network.asciidoc[]

include::vsphere/virtualmachine.asciidoc[]

:edit_url!:
29 changes: 29 additions & 0 deletions metricbeat/docs/modules/vsphere/network.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
////
This file is generated! See scripts/mage/docs_collector.go
////
:edit_url: https://github.com/elastic/beats/edit/main/metricbeat/module/vsphere/network/_meta/docs.asciidoc


[[metricbeat-metricset-vsphere-network]]
=== vSphere network metricset

beta[]

include::../../../module/vsphere/network/_meta/docs.asciidoc[]

This is a default metricset. If the host module is unconfigured, this metricset is enabled by default.

:edit_url:

==== Fields

For a description of each field in the metricset, see the
<<exported-fields-vsphere,exported fields>> section.

Here is an example document generated by this metricset:

[source,json]
----
include::../../../module/vsphere/network/_meta/data.json[]
----
:edit_url!:
3 changes: 2 additions & 1 deletion metricbeat/docs/modules_list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,9 @@ This file is generated! See scripts/mage/docs_collector.go
|<<metricbeat-module-uwsgi,uWSGI>> |image:./images/icon-yes.png[Prebuilt dashboards are available] |
.1+| .1+| |<<metricbeat-metricset-uwsgi-status,status>>
|<<metricbeat-module-vsphere,vSphere>> |image:./images/icon-yes.png[Prebuilt dashboards are available] |
.3+| .3+| |<<metricbeat-metricset-vsphere-datastore,datastore>>
.4+| .4+| |<<metricbeat-metricset-vsphere-datastore,datastore>>
|<<metricbeat-metricset-vsphere-host,host>>
|<<metricbeat-metricset-vsphere-network,network>> beta[]
|<<metricbeat-metricset-vsphere-virtualmachine,virtualmachine>>
|<<metricbeat-module-windows,Windows>> |image:./images/icon-yes.png[Prebuilt dashboards are available] |
.2+| .2+| |<<metricbeat-metricset-windows-perfmon,perfmon>>
Expand Down
1 change: 1 addition & 0 deletions metricbeat/include/list_common.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion metricbeat/metricbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ metricbeat.modules:
#------------------------------- VSphere Module -------------------------------
- module: vsphere
enabled: true
metricsets: ["datastore", "host", "virtualmachine"]
metricsets: ["datastore", "host", "virtualmachine", "network"]
# Real-time data collection – An ESXi Server collects data for each performance counter every 20 seconds.
period: 20s
hosts: ["https://localhost/sdk"]
Expand Down
1 change: 1 addition & 0 deletions metricbeat/module/vsphere/_meta/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Now setup your metricbeat config to connect to Govcsim:
- datastore
- host
- virtualmachine
- network
enabled: true
period: 5s
hosts: ["https://127.0.0.1:8989/sdk"]
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/vsphere/_meta/config.reference.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- module: vsphere
enabled: true
metricsets: ["datastore", "host", "virtualmachine"]
metricsets: ["datastore", "host", "virtualmachine", "network"]
# Real-time data collection – An ESXi Server collects data for each performance counter every 20 seconds.
period: 20s
hosts: ["https://localhost/sdk"]
Expand Down
1 change: 1 addition & 0 deletions metricbeat/module/vsphere/_meta/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# - datastore
# - host
# - virtualmachine
# - network
# Real-time data collection – An ESXi Server collects data for each performance counter every 20 seconds.
period: 20s
hosts: ["https://localhost/sdk"]
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/vsphere/_meta/docs.asciidoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The vSphere module uses the https://github.com/vmware/govmomi[Govmomi] library to collect metrics from any Vmware SDK URL (ESXi/VCenter). This library is built for and tested against ESXi and vCenter 5.5, 6.0 and 6.5.

By default it enables the metricsets `datastore`, `host` and `virtualmachine`.
By default it enables the metricsets `network`, `datastore`, `host` and `virtualmachine`.

[float]
=== Dashboard
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/vsphere/fields.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 21 additions & 19 deletions metricbeat/module/vsphere/host/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import (
"github.com/elastic/elastic-agent-libs/mapstr"
)

func (m *MetricSet) eventMapping(hs mo.HostSystem, data *metricData) mapstr.M {
func (m *HostMetricSet) mapEvent(hs mo.HostSystem, data *metricData) mapstr.M {
const bytesMultiplier int64 = 1024 * 1024
event := mapstr.M{
"name": hs.Summary.Config.Name,
"status": hs.Summary.OverallStatus,
Expand All @@ -35,7 +36,7 @@ func (m *MetricSet) eventMapping(hs mo.HostSystem, data *metricData) mapstr.M {

if hw := hs.Summary.Hardware; hw != nil {
totalCPU := int64(hw.CpuMhz) * int64(hw.NumCpuCores)
usedMemory := int64(hs.Summary.QuickStats.OverallMemoryUsage) * 1024 * 1024
usedMemory := int64(hs.Summary.QuickStats.OverallMemoryUsage) * bytesMultiplier
event.Put("cpu.total.mhz", totalCPU)
event.Put("cpu.free.mhz", totalCPU-int64(hs.Summary.QuickStats.OverallCpuUsage))
event.Put("memory.used.bytes", usedMemory)
Expand All @@ -45,28 +46,29 @@ func (m *MetricSet) eventMapping(hs mo.HostSystem, data *metricData) mapstr.M {
m.Logger().Debug("'Hardware' or 'Summary' data not found. This is either a parsing error from vsphere library, an error trying to reach host/guest or incomplete information returned from host/guest")
}

if len(data.assetsName.outputVmNames) > 0 {
event.Put("vm.names", data.assetsName.outputVmNames)
event.Put("vm.count", len(data.assetsName.outputVmNames))
if len(data.assetNames.outputVmNames) > 0 {
event.Put("vm.names", data.assetNames.outputVmNames)
event.Put("vm.count", len(data.assetNames.outputVmNames))
}

if len(data.assetsName.outputDsNames) > 0 {
event.Put("datastore.names", data.assetsName.outputDsNames)
event.Put("datastore.count", len(data.assetsName.outputDsNames))
if len(data.assetNames.outputDsNames) > 0 {
event.Put("datastore.names", data.assetNames.outputDsNames)
event.Put("datastore.count", len(data.assetNames.outputDsNames))
}

if len(data.assetsName.outputNetworkNames) > 0 {
event.Put("network_names", data.assetsName.outputNetworkNames)
event.Put("network.names", data.assetsName.outputNetworkNames)
event.Put("network.count", len(data.assetsName.outputNetworkNames))
if len(data.assetNames.outputNetworkNames) > 0 {
event.Put("network_names", data.assetNames.outputNetworkNames)
event.Put("network.names", data.assetNames.outputNetworkNames)
event.Put("network.count", len(data.assetNames.outputNetworkNames))
}

return event
}

func mapPerfMetricToEvent(event mapstr.M, perfMetricMap map[string]interface{}) {
const bytesMultiplier int64 = 1024
if val, exist := perfMetricMap["disk.capacity.usage.average"]; exist {
event.Put("disk.capacity.usage.bytes", val.(int64)*1000)
event.Put("disk.capacity.usage.bytes", val.(int64)*bytesMultiplier)
}
if val, exist := perfMetricMap["disk.deviceLatency.average"]; exist {
event.Put("disk.devicelatency.average.ms", val)
Expand All @@ -75,23 +77,23 @@ func mapPerfMetricToEvent(event mapstr.M, perfMetricMap map[string]interface{})
event.Put("disk.latency.total.ms", val)
}
if val, exist := perfMetricMap["disk.usage.average"]; exist {
event.Put("disk.total.bytes", val.(int64)*1000)
event.Put("disk.total.bytes", val.(int64)*bytesMultiplier)
}
if val, exist := perfMetricMap["disk.read.average"]; exist {
event.Put("disk.read.bytes", val.(int64)*1000)
event.Put("disk.read.bytes", val.(int64)*bytesMultiplier)
}
if val, exist := perfMetricMap["disk.write.average"]; exist {
event.Put("disk.write.bytes", val.(int64)*1000)
event.Put("disk.write.bytes", val.(int64)*bytesMultiplier)
}

if val, exist := perfMetricMap["net.transmitted.average"]; exist {
event.Put("network.bandwidth.transmitted.bytes", val.(int64)*1000)
event.Put("network.bandwidth.transmitted.bytes", val.(int64)*bytesMultiplier)
}
if val, exist := perfMetricMap["net.received.average"]; exist {
event.Put("network.bandwidth.received.bytes", val.(int64)*1000)
event.Put("network.bandwidth.received.bytes", val.(int64)*bytesMultiplier)
}
if val, exist := perfMetricMap["net.usage.average"]; exist {
event.Put("network.bandwidth.total.bytes", val.(int64)*1000)
event.Put("network.bandwidth.total.bytes", val.(int64)*bytesMultiplier)
}

if val, exist := perfMetricMap["net.packetsTx.summation"]; exist {
Expand Down
Loading

0 comments on commit 93ee5ca

Please sign in to comment.