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

[vSphere][datastore] Add additional metrics #40441

Merged
merged 28 commits into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ea05a06
add data collection
niraj-elastic Aug 6, 2024
decfc87
update changelog
niraj-elastic Aug 6, 2024
de913ec
update datacollection
niraj-elastic Aug 6, 2024
0b49482
update fields.yml
niraj-elastic Aug 6, 2024
88387bf
update test files
niraj-elastic Aug 7, 2024
42bb440
update field discriptions
niraj-elastic Aug 8, 2024
e5bb66c
address review comments
niraj-elastic Aug 9, 2024
b2197e4
address review comments
niraj-elastic Aug 12, 2024
7616495
address review commetns
niraj-elastic Aug 13, 2024
f6e481e
update fields
niraj-crest Aug 13, 2024
dffe460
update usint test
niraj-crest Aug 13, 2024
c14f4fd
address review comments
niraj-crest Aug 20, 2024
80549e1
update data_test file
niraj-crest Aug 20, 2024
de70715
update unit test
niraj-crest Aug 20, 2024
34ce371
address review comments
niraj-crest Aug 20, 2024
6cb96c4
update fields.asci
niraj-crest Aug 20, 2024
c37bde1
address review comments
niraj-crest Aug 20, 2024
98b627f
update data_test file
niraj-crest Aug 20, 2024
c38b06d
update go.mod file
niraj-crest Aug 21, 2024
3ffc570
update NOTICE.txt
niraj-crest Aug 21, 2024
a875047
address review comment
niraj-crest Aug 21, 2024
2e35a11
Merge branch 'elastic:main' into vsphere_datastore_metricset
niraj-elastic Aug 21, 2024
eaa3429
address review comments
niraj-crest Aug 22, 2024
e38f7e2
Merge branch 'vsphere_datastore_metricset' of https://github.com/nira…
niraj-crest Aug 22, 2024
4931d09
Merge branch 'main' of https://github.com/niraj-elastic/beats into vs…
niraj-crest Aug 22, 2024
3479446
mage update
niraj-crest Aug 22, 2024
47893ac
address review comments
niraj-crest Aug 22, 2024
bc8f19b
Address review comments
niraj-crest Aug 23, 2024
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 CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- Add support of Graphite series 1.1.0+ tagging extension for statsd module. {pull}39619[39619]
- Remove fallback to the node limit for the `kubernetes.pod.cpu.usage.limit.pct` and `kubernetes.pod.memory.usage.limit.pct` metrics calculation
- Add support for Kibana status metricset in v8 format {pull}40275[40275]
- Add new metrics for the Vsphere Datastore metricset. {pull}40441[40441]
niraj-elastic marked this conversation as resolved.
Show resolved Hide resolved
niraj-elastic marked this conversation as resolved.
Show resolved Hide resolved

*Osquerybeat*

Expand Down
26 changes: 25 additions & 1 deletion metricbeat/module/vsphere/datastore/_meta/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
},
"vsphere": {
"datastore": {
"iops": 0,
"host": {
"count": 1
},
"status": "green",
"vm": {
"count": 6
},
"capacity": {
"free": {
"bytes": 37120094208
Expand All @@ -25,7 +33,23 @@
"used": {
"bytes": 37566570496,
"pct": 0.502988996026061
}
},
"read": {
"bytes": 0,
"latency": {
"total": {
"ms": 0
}
}
},
"write": {
"bytes": 337000,
"latency": {
"total": {
"ms": 0
}
}
}
},
"fstype": "local",
"name": "LocalDS_0"
Expand Down
62 changes: 48 additions & 14 deletions metricbeat/module/vsphere/datastore/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,66 @@
datastore
release: ga
harnish-elastic marked this conversation as resolved.
Show resolved Hide resolved
fields:
- name: name
type: keyword
description: >
Datastore name
- name: fstype
type: keyword
description: >
Filesystem type
- name: capacity.total.bytes
- name: capacity.free.bytes
type: long
description: >
Total bytes of the datastore
Free bytes of the datastore.
format: bytes
- name: capacity.free.bytes
- name: capacity.total.bytes
type: long
description: >
Free bytes of the datastore
Total bytes of the datastore.
format: bytes
- name: capacity.used.bytes
type: long
description: >
Used bytes of the datastore
Used bytes of the datastore.
format: bytes
- name: capacity.used.pct
type: scaled_float
description: >
Used percent of the datastore
Used percent of the datastore.
niraj-elastic marked this conversation as resolved.
Show resolved Hide resolved
format: percent
- name: fstype
type: keyword
description: >
Filesystem type
- name: host.count
type: long
description: >
Number of hosts.
- name: iops
type: long
description: >
Storage I/O Control aggregated IOPS.
niraj-elastic marked this conversation as resolved.
Show resolved Hide resolved
- name: name
type: keyword
description: >
Datastore name
- name: read.bytes
type: long
description: >
Rate of reading data from the datastore.
format: bytes
- name: read.latency.total.ms
type: double
niraj-elastic marked this conversation as resolved.
Show resolved Hide resolved
description: >
Average amount of time for a read operation from the datastore.
niraj-elastic marked this conversation as resolved.
Show resolved Hide resolved
- name: status
type: keyword
description: >
Status of the datastore.
- name: vm.count
type: long
description: >
Number of VMs.
- name: write.bytes
type: long
description: >
Rate of writing data to the datastore.
format: bytes
- name: write.latency.total.ms
type: double
niraj-elastic marked this conversation as resolved.
Show resolved Hide resolved
description: >
Average amount of time for a write operation from the datastore.
niraj-elastic marked this conversation as resolved.
Show resolved Hide resolved

74 changes: 74 additions & 0 deletions metricbeat/module/vsphere/datastore/data.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package datastore

import (
"github.com/vmware/govmomi/vim25/mo"

"github.com/elastic/elastic-agent-libs/mapstr"
)

func (m *MetricSet) eventMapping(ds mo.Datastore, perfMertics *PerformanceMetrics) mapstr.M {
var usedSpacePercent float64
if ds.Summary.Capacity > 0 {
usedSpacePercent = float64(ds.Summary.Capacity-ds.Summary.FreeSpace) / float64(ds.Summary.Capacity)
}
niraj-elastic marked this conversation as resolved.
Show resolved Hide resolved
usedSpaceBytes := ds.Summary.Capacity - ds.Summary.FreeSpace

event := mapstr.M{
"read": mapstr.M{
"bytes": perfMertics.DsRead * 1000,
"latency": mapstr.M{
"total": mapstr.M{
"ms": perfMertics.DsReadLatency,
},
},
},
"write": mapstr.M{
"bytes": perfMertics.DsWrite * 1000,
"latency": mapstr.M{
"total": mapstr.M{
"ms": perfMertics.DsWriteLatency,
},
},
},
"iops": perfMertics.DsIops,
"name": ds.Summary.Name,
"fstype": ds.Summary.Type,
"status": ds.OverallStatus,
"host": mapstr.M{
"count": len(ds.Host),
},
"vm": mapstr.M{
"count": len(ds.Vm),
},
niraj-elastic marked this conversation as resolved.
Show resolved Hide resolved
"capacity": mapstr.M{
"total": mapstr.M{
"bytes": ds.Summary.Capacity,
},
"free": mapstr.M{
"bytes": ds.Summary.FreeSpace,
},
"used": mapstr.M{
"bytes": usedSpaceBytes,
"pct": usedSpacePercent,
},
},
}
return event
}
63 changes: 63 additions & 0 deletions metricbeat/module/vsphere/datastore/data_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package datastore

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/vmware/govmomi/vim25/mo"
"github.com/vmware/govmomi/vim25/types"
)

func TestEventMapping(t *testing.T) {
var m *MetricSet
var DatastoreTest = mo.Datastore{
devamanv marked this conversation as resolved.
Show resolved Hide resolved
Summary: types.DatastoreSummary{
Name: "datastore-test",
Type: "local",
Capacity: 5000000,
FreeSpace: 5000000,
},
ManagedEntity: mo.ManagedEntity{
OverallStatus: "green",
},
Host: []types.DatastoreHostMount{},
Vm: []types.ManagedObjectReference{
{Type: "VirtualMachine", Value: "vm-test"},
},
}

event := m.eventMapping(DatastoreTest, &PerformanceMetrics{})

VmCount, _ := event.GetValue("vm.count")
assert.EqualValues(t, 1, VmCount)

capacityTotal, _ := event.GetValue("capacity.total.bytes")
assert.EqualValues(t, 5000000, capacityTotal)

capacityFree, _ := event.GetValue("capacity.free.bytes")
assert.EqualValues(t, 5000000, capacityFree)

capacityUsed, _ := event.GetValue("capacity.used.bytes")
assert.EqualValues(t, 0, capacityUsed)

capacityUsedPct, _ := event.GetValue("capacity.used.pct")
assert.EqualValues(t, 0, capacityUsedPct)

}
Loading
Loading