Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable netinfo in add metadata processors #16077

Merged
merged 7 commits into from
Feb 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,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 @@ -1554,8 +1554,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