Skip to content

Commit

Permalink
Add OS Name into add-host-metadata (#9405) (#9471)
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

(cherry picked from commit 2a9c217)
  • Loading branch information
kaiyan-sheng committed Dec 11, 2018
1 parent 287fdd7 commit 64d8258
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Expand Up @@ -111,6 +111,7 @@ https://github.com/elastic/beats/compare/v6.5.0...6.x[Check the HEAD diff]
- Test etcd module with etcd 3.3. {pull}9068[9068]
- Add setting to disable docker cpu metrics per core. {pull}9194[9194]
- The `elasticsearch/node` metricset now reports the Elasticsearch cluster UUID. {pull}8771[8771]
- 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
Expand Up @@ -917,7 +917,8 @@ The fields added to the event are looking as following:
"family":"darwin",
"build":"16G1212",
"platform":"darwin",
"version":"10.12.6"
"version":"10.12.6",
"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
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,
},
},
}
Expand Down Expand Up @@ -72,6 +73,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)

if info.OS.Codename != "" {
monitoring.ReportString(V, "codename", info.OS.Codename)
Expand Down
Expand Up @@ -51,6 +51,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 @@ -84,6 +88,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 64d8258

Please sign in to comment.