Skip to content

Commit

Permalink
Add OS Name into add-host-metadata (#9405)
Browse files Browse the repository at this point in the history
* Add OS Name into add-host-metadat

* Run gofmt

* Add changelog and update documentation

* Update changelog
  • Loading branch information
kaiyan-sheng authored Dec 7, 2018
1 parent e6d8623 commit 2a9c217
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha1...master[Check the HEAD d
- The `elasticsearch/node` metricset now reports the Elasticsearch cluster UUID. {pull}8771[8771]
- Add service.type field to Metricbeat. {pull}8965[8965]
- Support GET requests in Jolokia module. {issue}8566[8566] {pull}9226[9226]
- Add `host.os.name` field to add_host_metadata processor. {issue}8948[8948] {pull}9405[9405]

*Packetbeat*

Expand Down
3 changes: 2 additions & 1 deletion libbeat/docs/processors-using.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,8 @@ The fields added to the event are looking as following:
"build":"16G1212",
"platform":"darwin",
"version":"10.12.6",
"kernel":"16.7.0"
"kernel":"16.7.0",
"name":"Mac OS X"
},
"ip": ["192.168.0.1", "10.0.0.1"],
"mac": ["00:25:96:12:34:56", "72:00:06:ff:79:f1"]
Expand Down
2 changes: 2 additions & 0 deletions libbeat/metric/system/host/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func MapHostInfo(info types.HostInfo) common.MapStr {
"platform": info.OS.Platform,
"version": info.OS.Version,
"family": info.OS.Family,
"name": info.OS.Name,
"kernel": info.KernelVersion,
},
},
Expand Down Expand Up @@ -73,6 +74,7 @@ func ReportInfo(_ monitoring.Mode, V monitoring.Visitor) {
monitoring.ReportString(V, "platform", info.OS.Platform)
monitoring.ReportString(V, "version", info.OS.Version)
monitoring.ReportString(V, "family", info.OS.Family)
monitoring.ReportString(V, "name", info.OS.Name)
monitoring.ReportString(V, "kernel", info.KernelVersion)

if info.OS.Codename != "" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ func TestConfigDefault(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, v)

v, err = newEvent.GetValue("host.os.name")
assert.NoError(t, err)
assert.NotNil(t, v)

v, err = newEvent.GetValue("host.ip")
assert.Error(t, err)
assert.Nil(t, v)
Expand Down Expand Up @@ -96,6 +100,10 @@ func TestConfigNetInfoEnabled(t *testing.T) {
assert.NoError(t, err)
assert.NotNil(t, v)

v, err = newEvent.GetValue("host.os.name")
assert.NoError(t, err)
assert.NotNil(t, v)

v, err = newEvent.GetValue("host.ip")
assert.NoError(t, err)
assert.NotNil(t, v)
Expand Down

0 comments on commit 2a9c217

Please sign in to comment.