Skip to content

Commit

Permalink
Cherry-pick #23148 to 7.11: Fix vsphere.datastore.capacity.used.pct v…
Browse files Browse the repository at this point in the history
…alue by removing *100 (#23168)

(cherry picked from commit 1e9b07c)
  • Loading branch information
kaiyan-sheng committed Dec 17, 2020
1 parent 7ef478f commit 3d74ac9
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Update NATS dashboards to leverage connection and route metricsets {pull}22646[22646]
- Fix rate metrics in Kafka broker metricset by using last minute rate instead of mean rate. {pull}22733[22733]
- Fix `logstash` module when `xpack.enabled: true` is set from emitting redundant events. {pull}22808[22808]
- 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 @@ -46400,7 +46400,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.

0 comments on commit 3d74ac9

Please sign in to comment.