diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 512ad3f60ff..cc38c362513 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -257,6 +257,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d - Fix checking tagsFilter using length in cloudwatch metricset. {pull}14525[14525] - Log bulk failures from bulk API requests to monitoring cluster. {issue}14303[14303] {pull}14356[14356] - Fixed bug with `elasticsearch/cluster_stats` metricset not recording license expiration date correctly. {issue}14541[14541] {pull}14591[14591] +- Vshpere module splits `virtualmachine.host` into `virtualmachine.host.id` and `virtualmachine.host.hostname`. {issue}7187[7187] {pull}7213[7213] *Packetbeat* diff --git a/metricbeat/docs/fields.asciidoc b/metricbeat/docs/fields.asciidoc index 371133c37ab..7eb5b5975ac 100644 --- a/metricbeat/docs/fields.asciidoc +++ b/metricbeat/docs/fields.asciidoc @@ -32469,10 +32469,20 @@ virtualmachine -*`vsphere.virtualmachine.host`*:: +*`vsphere.virtualmachine.host.id`*:: + -- -Host name +Host id + + +type: keyword + +-- + +*`vsphere.virtualmachine.host.hostname`*:: ++ +-- +Host name of the host type: keyword diff --git a/metricbeat/magefile.go b/metricbeat/magefile.go index e1521193fe1..d061ae500ce 100644 --- a/metricbeat/magefile.go +++ b/metricbeat/magefile.go @@ -51,7 +51,6 @@ import ( func init() { common.RegisterCheckDeps(update.Update) - devtools.BeatDescription = "Metricbeat is a lightweight shipper for metrics." } diff --git a/metricbeat/module/vsphere/fields.go b/metricbeat/module/vsphere/fields.go index d199abd80d0..22e671f12f5 100644 --- a/metricbeat/module/vsphere/fields.go +++ b/metricbeat/module/vsphere/fields.go @@ -32,5 +32,5 @@ func init() { // AssetVsphere returns asset data. // This is the base64 encoded gzipped contents of ../metricbeat/module/vsphere. func AssetVsphere() string { - return "eJzMlsFymzAQhu9+ip3ckwfg0Es6aS9uO5OmV48Mi1GNWI20JEOfviMJPBjkJDWirQ6eMQv//3nF/tYtHL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+O9l8c7E1F+8XLwlT2egbimlpWC5ZXvFl1dllUektu2ejb8/BJ10ZXIDgxsz8bpeXQUII83yqlf/iNgIPfieXAlgm/stD0q0LNiDdnePDHuPfWNsYxem7R0GZhKkv4ZA1Wx5ZjdR/rhqi+UJLkf/rXOukCyd6rawfpYcdNYT1r3hqS4uhDM0ooTz9xdiD2k8cVlX3njCFi/E8b1+8AAAD//7eBEp0=" } diff --git a/metricbeat/module/vsphere/virtualmachine/_meta/data.json b/metricbeat/module/vsphere/virtualmachine/_meta/data.json index bf542bfbf66..cae229ceaeb 100644 --- a/metricbeat/module/vsphere/virtualmachine/_meta/data.json +++ b/metricbeat/module/vsphere/virtualmachine/_meta/data.json @@ -17,7 +17,8 @@ "mhz": 0 } }, - "host": "ha-host", + "host.id": "ha-host", + "host.hostname": "localhost.localdomain", "memory": { "free": { "guest": { @@ -41,4 +42,4 @@ "name": "ha-host_VM1" } } -} \ No newline at end of file +} diff --git a/metricbeat/module/vsphere/virtualmachine/_meta/fields.yml b/metricbeat/module/vsphere/virtualmachine/_meta/fields.yml index bc58b7dd58e..f7bc14d856f 100644 --- a/metricbeat/module/vsphere/virtualmachine/_meta/fields.yml +++ b/metricbeat/module/vsphere/virtualmachine/_meta/fields.yml @@ -4,10 +4,14 @@ virtualmachine release: beta fields: - - name: host + - name: host.id type: keyword description: > - Host name + Host id + - name: host.hostname + type: keyword + description: > + Host name of the host - name: name type: keyword description: > diff --git a/metricbeat/module/vsphere/virtualmachine/virtualmachine.go b/metricbeat/module/vsphere/virtualmachine/virtualmachine.go index 1d211711d9d..fae77b32fe8 100644 --- a/metricbeat/module/vsphere/virtualmachine/virtualmachine.go +++ b/metricbeat/module/vsphere/virtualmachine/virtualmachine.go @@ -151,12 +151,12 @@ func (m *MetricSet) Fetch(ctx context.Context, reporter mb.ReporterV2) error { "bytes": (int64(vm.Summary.QuickStats.GuestMemoryUsage) * 1024 * 1024), }, "host": common.MapStr{ - "bytes": (int64(vm.Summary.QuickStats.HostMemoryUsage) * 1024 * 1024), + "bytes": int64(vm.Summary.QuickStats.HostMemoryUsage) * 1024 * 1024, }, }, "total": common.MapStr{ "guest": common.MapStr{ - "bytes": (int64(vm.Summary.Config.MemorySizeMB) * 1024 * 1024), + "bytes": int64(vm.Summary.Config.MemorySizeMB) * 1024 * 1024, }, }, "free": common.MapStr{ @@ -168,13 +168,19 @@ func (m *MetricSet) Fetch(ctx context.Context, reporter mb.ReporterV2) error { } if vm.Summary.Runtime.Host != nil { - event["host"] = vm.Summary.Runtime.Host.Value + event["host.id"] = vm.Summary.Runtime.Host.Value } else { m.Logger().Debug("'Host', 'Runtime' 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") } + hostSystem, err := getHostSystem(ctx, c, vm.Summary.Runtime.Host.Reference()) + if err != nil { + m.Logger().Debug(err.Error()) + } else { + event["host.hostname"] = hostSystem.Summary.Config.Name + } // Get custom fields (attributes) values if get_custom_fields is true. if m.GetCustomFields && vm.Summary.CustomValue != nil { customFields := getCustomFields(vm.Summary.CustomValue, customFieldsMap) @@ -285,3 +291,14 @@ func setCustomFieldsMap(ctx context.Context, client *vim25.Client) (map[int32]st return customFieldsMap, nil } + +func getHostSystem(ctx context.Context, c *vim25.Client, ref types.ManagedObjectReference) (*mo.HostSystem, error) { + pc := property.DefaultCollector(c) + + var hs mo.HostSystem + err := pc.RetrieveOne(ctx, ref, []string{"summary"}, &hs) + if err != nil { + return nil, fmt.Errorf("error retrieving host information: %v", err) + } + return &hs, nil +} diff --git a/metricbeat/module/vsphere/virtualmachine/virtualmachine_test.go b/metricbeat/module/vsphere/virtualmachine/virtualmachine_test.go index 8b850f3450e..fb640c48fdc 100644 --- a/metricbeat/module/vsphere/virtualmachine/virtualmachine_test.go +++ b/metricbeat/module/vsphere/virtualmachine/virtualmachine_test.go @@ -48,7 +48,8 @@ func TestFetchEventContents(t *testing.T) { t.Logf("%s/%s event: %+v", f.Module().Name(), f.Name(), event.StringToPrint()) - assert.EqualValues(t, "ha-host", event["host"]) + assert.EqualValues(t, "ha-host", event["host.id"]) + assert.EqualValues(t, "localhost.localdomain", event["host.hostname"]) assert.True(t, strings.Contains(event["name"].(string), "ha-host_VM")) cpu := event["cpu"].(common.MapStr)