-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[vSphere][datastore_cluster] Add support for new metrics in datastore…
…_cluster metricset (#40634) * initial commit for datastore cluster * mage update * update: - data.json - field.yml * doc updates * datastore_cluster -> datastorecluster * resolve review comments * fix UTs * update URL for UTs * update UTs * fix field mapping * update data.json
- Loading branch information
1 parent
7f317fd
commit 30320a3
Showing
20 changed files
with
415 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/datastorecluster/_meta/docs.asciidoc | ||
|
||
|
||
[[metricbeat-metricset-vsphere-datastorecluster]] | ||
=== vSphere datastorecluster metricset | ||
|
||
beta[] | ||
|
||
include::../../../module/vsphere/datastorecluster/_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/datastorecluster/_meta/data.json[] | ||
---- | ||
:edit_url!: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
metricbeat/module/vsphere/datastorecluster/_meta/data.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"@timestamp": "2016-05-23T08:05:34.853Z", | ||
"service": { | ||
"address": "https://localhost:8980/sdk", | ||
"type": "vsphere" | ||
}, | ||
"event": { | ||
"dataset": "vsphere.datastorecluster", | ||
"module": "vsphere", | ||
"duration": 15443161 | ||
}, | ||
"metricset": { | ||
"period": 20000, | ||
"name": "datastorecluster" | ||
}, | ||
"vsphere": { | ||
"datastorecluster": { | ||
"name": "datastore_cluster1", | ||
"capacity": { | ||
"bytes": 8795019280384 | ||
}, | ||
"free_space": { | ||
"bytes": 8788836876288 | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is the Datastore Cluster metricset of the module vsphere. |
20 changes: 20 additions & 0 deletions
20
metricbeat/module/vsphere/datastorecluster/_meta/fields.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
- name: datastorecluster | ||
type: group | ||
release: beta | ||
description: > | ||
Datastore Cluster | ||
fields: | ||
- name: name | ||
type: keyword | ||
description: > | ||
The Datastore Cluster name. | ||
- name: capacity.bytes | ||
type: long | ||
description: > | ||
Total capacity of this storage pod, in bytes. | ||
format: bytes | ||
- name: free_space.bytes | ||
type: long | ||
description: > | ||
Total free space on this storage pod, in bytes. | ||
format: bytes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// 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 datastorecluster | ||
|
||
import ( | ||
"github.com/vmware/govmomi/vim25/mo" | ||
|
||
"github.com/elastic/elastic-agent-libs/mapstr" | ||
) | ||
|
||
func (m *DatastoreClusterMetricSet) mapEvent(datastoreCluster mo.StoragePod) mapstr.M { | ||
event := mapstr.M{} | ||
|
||
event.Put("name", datastoreCluster.Name) | ||
event.Put("capacity.bytes", datastoreCluster.Summary.Capacity) | ||
event.Put("free_space.bytes", datastoreCluster.Summary.FreeSpace) | ||
|
||
return event | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// 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 datastorecluster | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/vmware/govmomi/vim25/mo" | ||
"github.com/vmware/govmomi/vim25/types" | ||
) | ||
|
||
func TestEventMapping(t *testing.T) { | ||
datastoreClusterTest := mo.StoragePod{ | ||
Summary: &types.StoragePodSummary{ | ||
Capacity: 100, | ||
FreeSpace: 50, | ||
}, | ||
Folder: mo.Folder{ | ||
ManagedEntity: mo.ManagedEntity{ | ||
Name: "Folder1", | ||
}, | ||
}, | ||
} | ||
|
||
event := (&DatastoreClusterMetricSet{}).mapEvent(datastoreClusterTest) | ||
|
||
name, _ := event.GetValue("name") | ||
assert.Equal(t, "Folder1", name) | ||
|
||
capacity, _ := event.GetValue("capacity.bytes") | ||
assert.Equal(t, int64(100), capacity) | ||
|
||
freeSpace, _ := event.GetValue("free_space.bytes") | ||
assert.Equal(t, int64(50), freeSpace) | ||
} |
Oops, something went wrong.