Skip to content

Commit

Permalink
Enable netinfo in add metadata processors (elastic#16077)
Browse files Browse the repository at this point in the history
Enable netinfo in add_host_metadata and add_observer_metadata processors
by default. This network information metadata is used in observability solutions.

Co-authored-by: Dan Roscigno <dan@roscigno.com>
  • Loading branch information
2 people authored and kvch committed Feb 20, 2020
1 parent 918e308 commit 2d0de5d
Show file tree
Hide file tree
Showing 20 changed files with 38 additions and 52 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
*Affecting all Beats*

- Add document_id setting to decode_json_fields processor. {pull}15859[15859]
- Include network information by default on add_host_metadata and add_observer_metadata. {issue}15347[15347] {pull}16077[16077]
- Add `aws_ec2` provider for autodiscover. {issue}12518[12518] {pull}14823[14823]

*Auditbeat*
Expand Down
3 changes: 1 addition & 2 deletions auditbeat/auditbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,7 @@ auditbeat.modules:
# The following example enriches each event with host metadata.
#
#processors:
#- add_host_metadata:
# netinfo.enabled: false
#- add_host_metadata: ~
#
# The following example enriches each event with process metadata using
# process IDs included in the event.
Expand Down
3 changes: 1 addition & 2 deletions filebeat/filebeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1020,8 +1020,7 @@ filebeat.inputs:
# The following example enriches each event with host metadata.
#
#processors:
#- add_host_metadata:
# netinfo.enabled: false
#- add_host_metadata: ~
#
# The following example enriches each event with process metadata using
# process IDs included in the event.
Expand Down
3 changes: 1 addition & 2 deletions heartbeat/heartbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,7 @@ heartbeat.scheduler:
# The following example enriches each event with host metadata.
#
#processors:
#- add_host_metadata:
# netinfo.enabled: false
#- add_host_metadata: ~
#
# The following example enriches each event with process metadata using
# process IDs included in the event.
Expand Down
3 changes: 1 addition & 2 deletions journalbeat/journalbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,7 @@ setup.template.settings:
# The following example enriches each event with host metadata.
#
#processors:
#- add_host_metadata:
# netinfo.enabled: false
#- add_host_metadata: ~
#
# The following example enriches each event with process metadata using
# process IDs included in the event.
Expand Down
3 changes: 1 addition & 2 deletions libbeat/_meta/config.reference.yml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@
# The following example enriches each event with host metadata.
#
#processors:
#- add_host_metadata:
# netinfo.enabled: false
#- add_host_metadata: ~
#
# The following example enriches each event with process metadata using
# process IDs included in the event.
Expand Down
20 changes: 10 additions & 10 deletions libbeat/processors/add_host_metadata/add_host_metadata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,21 @@ func TestConfigDefault(t *testing.T) {
assert.NotNil(t, v)

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

v, err = newEvent.GetValue("host.mac")
assert.Error(t, err)
assert.Nil(t, v)
assert.NoError(t, err)
assert.NotNil(t, v)
}

func TestConfigNetInfoEnabled(t *testing.T) {
func TestConfigNetInfoDisabled(t *testing.T) {
event := &beat.Event{
Fields: common.MapStr{},
Timestamp: time.Now(),
}
testConfig, err := common.NewConfigFrom(map[string]interface{}{
"netinfo.enabled": true,
"netinfo.enabled": false,
})
assert.NoError(t, err)

Expand Down Expand Up @@ -107,12 +107,12 @@ func TestConfigNetInfoEnabled(t *testing.T) {
assert.NotNil(t, v)

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

v, err = newEvent.GetValue("host.mac")
assert.NoError(t, err)
assert.NotNil(t, v)
assert.Error(t, err)
assert.Nil(t, v)
}

func TestConfigName(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion libbeat/processors/add_host_metadata/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type Config struct {

func defaultConfig() Config {
return Config{
NetInfoEnabled: false,
NetInfoEnabled: true,
CacheTTL: 5 * time.Minute,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
-------------------------------------------------------------------------------
processors:
- add_host_metadata:
netinfo.enabled: false
cache.ttl: 5m
geo:
name: nyc-dc1-rack1
Expand All @@ -19,7 +18,7 @@ processors:

It has the following settings:

`netinfo.enabled`:: (Optional) Default false. Include IP addresses and MAC addresses as fields host.ip and host.mac
`netinfo.enabled`:: (Optional) Default true. Include IP addresses and MAC addresses as fields host.ip and host.mac

`cache.ttl`:: (Optional) The processor uses an internal cache for the host metadata. This sets the cache expiration time. The default is 5m, negative values disable caching altogether.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ func TestConfigDefault(t *testing.T) {
assert.NoError(t, err)

v, err := newEvent.GetValue("observer.ip")
assert.Error(t, err)
assert.Nil(t, v)
assert.NoError(t, err)
assert.NotNil(t, v)

v, err = newEvent.GetValue("observer.mac")
assert.Error(t, err)
assert.Nil(t, v)
assert.NoError(t, err)
assert.NotNil(t, v)
}

func TestOverwriteFalse(t *testing.T) {
Expand Down Expand Up @@ -86,13 +86,13 @@ func TestOverwriteTrue(t *testing.T) {
assert.NotNil(t, v)
}

func TestConfigNetInfoEnabled(t *testing.T) {
func TestConfigNetInfoDisabled(t *testing.T) {
event := &beat.Event{
Fields: common.MapStr{},
Timestamp: time.Now(),
}
testConfig, err := common.NewConfigFrom(map[string]interface{}{
"netinfo.enabled": true,
"netinfo.enabled": false,
})
assert.NoError(t, err)

Expand All @@ -102,12 +102,12 @@ func TestConfigNetInfoEnabled(t *testing.T) {
assert.NoError(t, err)

v, err := newEvent.GetValue("observer.ip")
assert.NoError(t, err)
assert.NotNil(t, v)
assert.Error(t, err)
assert.Nil(t, v)

v, err = newEvent.GetValue("observer.mac")
assert.NoError(t, err)
assert.NotNil(t, v)
assert.Error(t, err)
assert.Nil(t, v)
}

func TestConfigGeoEnabled(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion libbeat/processors/add_observer_metadata/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type Config struct {

func defaultConfig() Config {
return Config{
NetInfoEnabled: false,
NetInfoEnabled: true,
CacheTTL: 5 * time.Minute,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ beta[]
-------------------------------------------------------------------------------
processors:
- add_observer_metadata:
netinfo.enabled: false
cache.ttl: 5m
geo:
name: nyc-dc1-rack1
Expand All @@ -21,7 +20,7 @@ processors:

It has the following settings:

`netinfo.enabled`:: (Optional) Default false. Include IP addresses and MAC addresses as fields observer.ip and observer.mac
`netinfo.enabled`:: (Optional) Default true. Include IP addresses and MAC addresses as fields observer.ip and observer.mac

`cache.ttl`:: (Optional) The processor uses an internal cache for the observer metadata. This sets the cache expiration time. The default is 5m, negative values disable caching altogether.

Expand Down
3 changes: 1 addition & 2 deletions metricbeat/metricbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1004,8 +1004,7 @@ metricbeat.modules:
# The following example enriches each event with host metadata.
#
#processors:
#- add_host_metadata:
# netinfo.enabled: false
#- add_host_metadata: ~
#
# The following example enriches each event with process metadata using
# process IDs included in the event.
Expand Down
3 changes: 1 addition & 2 deletions packetbeat/packetbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -742,8 +742,7 @@ packetbeat.ignore_outgoing: false
# The following example enriches each event with host metadata.
#
#processors:
#- add_host_metadata:
# netinfo.enabled: false
#- add_host_metadata: ~
#
# The following example enriches each event with process metadata using
# process IDs included in the event.
Expand Down
3 changes: 1 addition & 2 deletions winlogbeat/winlogbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,7 @@ winlogbeat.event_logs:
# The following example enriches each event with host metadata.
#
#processors:
#- add_host_metadata:
# netinfo.enabled: false
#- add_host_metadata: ~
#
# The following example enriches each event with process metadata using
# process IDs included in the event.
Expand Down
3 changes: 1 addition & 2 deletions x-pack/auditbeat/auditbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,7 @@ auditbeat.modules:
# The following example enriches each event with host metadata.
#
#processors:
#- add_host_metadata:
# netinfo.enabled: false
#- add_host_metadata: ~
#
# The following example enriches each event with process metadata using
# process IDs included in the event.
Expand Down
3 changes: 1 addition & 2 deletions x-pack/filebeat/filebeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1566,8 +1566,7 @@ filebeat.inputs:
# The following example enriches each event with host metadata.
#
#processors:
#- add_host_metadata:
# netinfo.enabled: false
#- add_host_metadata: ~
#
# The following example enriches each event with process metadata using
# process IDs included in the event.
Expand Down
3 changes: 1 addition & 2 deletions x-pack/functionbeat/functionbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -581,8 +581,7 @@ functionbeat.provider.gcp.functions:
# The following example enriches each event with host metadata.
#
#processors:
#- add_host_metadata:
# netinfo.enabled: false
#- add_host_metadata: ~
#
# The following example enriches each event with process metadata using
# process IDs included in the event.
Expand Down
3 changes: 1 addition & 2 deletions x-pack/metricbeat/metricbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1237,8 +1237,7 @@ metricbeat.modules:
# The following example enriches each event with host metadata.
#
#processors:
#- add_host_metadata:
# netinfo.enabled: false
#- add_host_metadata: ~
#
# The following example enriches each event with process metadata using
# process IDs included in the event.
Expand Down
3 changes: 1 addition & 2 deletions x-pack/winlogbeat/winlogbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,7 @@ winlogbeat.event_logs:
# The following example enriches each event with host metadata.
#
#processors:
#- add_host_metadata:
# netinfo.enabled: false
#- add_host_metadata: ~
#
# The following example enriches each event with process metadata using
# process IDs included in the event.
Expand Down

0 comments on commit 2d0de5d

Please sign in to comment.