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

Fix vsphere.datastore.capacity.used.pct value by removing *100 #23148

Merged
merged 4 commits into from
Dec 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -467,6 +467,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Add support for azure light metricset app_stats. {pull}20639[20639]
- Fix remote_write flaky test. {pull}21173[21173]
- Remove io.time from windows {pull}22237[22237]
- Change vsphere.datastore.capacity.used.pct value to betweeen 0 and 1. {pull}23148[23148]

*Packetbeat*

Expand Down
2 changes: 1 addition & 1 deletion metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -46384,7 +46384,7 @@ format: bytes
Used percent of the datastore


type: long
type: scaled_float

format: percent

Expand Down
23 changes: 13 additions & 10 deletions metricbeat/module/vsphere/datastore/_meta/data.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
{
"@timestamp": "2017-10-12T08:05:34.853Z",
"beat": {
"hostname": "host.example.com",
"name": "host.example.com"
"event": {
"dataset": "vsphere.datastore",
"duration": 115000,
"module": "vsphere"
},
"metricset": {
"host": "http://127.0.0.1:36937/sdk",
"module": "vsphere",
"name": "datastore",
"rtt": 115
"period": 10000
},
"service": {
"address": "http://127.0.0.1:51027/sdk",
"type": "vsphere"
},
"vsphere": {
"datastore": {
"capacity": {
"free": {
"bytes": 50021150720
"bytes": 267958476800
},
"total": {
"bytes": 63918878720
"bytes": 484736266240
},
"used": {
"bytes": 13897728000,
"pct": 21
"bytes": 216777789440,
"pct": 0.44720769733509097
}
},
"fstype": "local",
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/vsphere/datastore/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
Used bytes of the datastore
format: bytes
- name: capacity.used.pct
type: long
type: scaled_float
description: >
Used percent of the datastore
format: percent
Expand Down
4 changes: 2 additions & 2 deletions metricbeat/module/vsphere/datastore/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ func (m *MetricSet) Fetch(ctx context.Context, reporter mb.ReporterV2) error {
}

for _, ds := range dst {
var usedSpacePercent int64
var usedSpacePercent float64
if ds.Summary.Capacity > 0 {
usedSpacePercent = 100 * (ds.Summary.Capacity - ds.Summary.FreeSpace) / ds.Summary.Capacity
usedSpacePercent = float64(ds.Summary.Capacity-ds.Summary.FreeSpace) / float64(ds.Summary.Capacity)
}
usedSpaceBytes := ds.Summary.Capacity - ds.Summary.FreeSpace

Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/vsphere/datastore/datastore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestFetchEventContents(t *testing.T) {

// Values are based on the result 'df -k'.
fields := []string{"capacity.total.bytes", "capacity.free.bytes",
"capacity.used.bytes", "capacity.used.pct"}
"capacity.used.bytes"}
for _, field := range fields {
value, err := event.GetValue(field)
if err != nil {
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.