From 29b2cc68e309ad10dbeb1789d42e7ca51612c472 Mon Sep 17 00:00:00 2001 From: simitt Date: Fri, 15 Feb 2019 14:44:12 +0100 Subject: [PATCH] Revert "Intoduce SkipAddHostName setting. (#10728)" This reverts commit 72df5e54015f353a166be373200563a6047d6db7. --- CHANGELOG-developer.next.asciidoc | 1 - libbeat/beat/pipeline.go | 4 -- libbeat/publisher/pipeline/module.go | 3 ++ libbeat/publisher/pipeline/processor.go | 11 +---- libbeat/publisher/pipeline/processor_test.go | 48 -------------------- 5 files changed, 4 insertions(+), 63 deletions(-) diff --git a/CHANGELOG-developer.next.asciidoc b/CHANGELOG-developer.next.asciidoc index 381c73c884e4..88bd7e48dbe9 100644 --- a/CHANGELOG-developer.next.asciidoc +++ b/CHANGELOG-developer.next.asciidoc @@ -35,4 +35,3 @@ The list below covers the major changes between 7.0.0-alpha2 and master only. - Introduce ILM and IndexManagement support to beat.Settings. {pull}10347[10347] - Generating index pattern on demand instead of shipping them in the packages. {pull}10478[10478] - Metricset generator generates beta modules by default now. {pull}10657[10657] -- Move host name addition to a processor. {pull}10728[10728] \ No newline at end of file diff --git a/libbeat/beat/pipeline.go b/libbeat/beat/pipeline.go index 435f48203ea0..3db7baae6d27 100644 --- a/libbeat/beat/pipeline.go +++ b/libbeat/beat/pipeline.go @@ -80,10 +80,6 @@ type ClientConfig struct { // To skip adding that metadata set this to true. SkipAgentMetadata bool - // By default events are decorated with a host name. - // To skip adding that host.name set this to true. - SkipHostName bool - // ACK handler strategies. // Note: ack handlers are run in another go-routine owned by the publisher pipeline. // They should not block for to long, to not block the internal buffers for diff --git a/libbeat/publisher/pipeline/module.go b/libbeat/publisher/pipeline/module.go index 7af329d84290..2c854c13676c 100644 --- a/libbeat/publisher/pipeline/module.go +++ b/libbeat/publisher/pipeline/module.go @@ -85,6 +85,9 @@ func Load( Annotations: Annotations{ Event: config.EventMetadata, Builtin: common.MapStr{ + "host": common.MapStr{ + "name": name, + }, "ecs": common.MapStr{ "version": "1.0.0-beta2", }, diff --git a/libbeat/publisher/pipeline/processor.go b/libbeat/publisher/pipeline/processor.go index 0dcaa59c98e8..81834f7bdff5 100644 --- a/libbeat/publisher/pipeline/processor.go +++ b/libbeat/publisher/pipeline/processor.go @@ -127,17 +127,12 @@ func newProcessorPipeline( processors.add(actions.NewAddFields(meta, needsCopy)) } - // setup 7: add agent metadata and host name + // setup 7: add agent metadata if !config.SkipAgentMetadata { needsCopy := global.alwaysCopy || global.processors != nil processors.add(actions.NewAddFields(createAgentFields(info), needsCopy)) } - if !config.SkipHostName { - needsCopy := global.alwaysCopy || global.processors != nil - processors.add(actions.NewAddFields(addHostName(info), needsCopy)) - } - // setup 8: pipeline processors list processors.add(global.processors) @@ -288,10 +283,6 @@ func createAgentFields(info beat.Info) common.MapStr { return common.MapStr{"agent": metadata} } -func addHostName(info beat.Info) common.MapStr { - return common.MapStr{"host": common.MapStr{"name": info.Name}} -} - func debugPrintProcessor(info beat.Info, monitors Monitors) *processorFn { // ensure only one go-routine is using the encoder (in case // beat.Client is shared between multiple go-routines by accident) diff --git a/libbeat/publisher/pipeline/processor_test.go b/libbeat/publisher/pipeline/processor_test.go index ea1e06c6a783..07b643d0c81c 100644 --- a/libbeat/publisher/pipeline/processor_test.go +++ b/libbeat/publisher/pipeline/processor_test.go @@ -38,7 +38,6 @@ func TestProcessors(t *testing.T) { events []common.MapStr expected []common.MapStr includeAgentMetadata bool - includeHostName bool } tests := []struct { @@ -149,52 +148,6 @@ func TestProcessors(t *testing.T) { }, }, }, - { - name: "add host name", - global: pipelineProcessors{ - fields: common.MapStr{"global": 1, "host": common.MapStr{"name": "host123"}}, - }, - info: &beat.Info{ - Hostname: "test.host.hostname", - Name: "test.host.name", - }, - local: []local{ - { - config: beat.ClientConfig{}, - events: []common.MapStr{{"value": "abc"}}, - expected: []common.MapStr{ - { - "host": common.MapStr{"name": "test.host.name"}, - "value": "abc", "global": 1, - }, - }, - includeHostName: true, - }, - }, - }, - { - name: "add host name to existing host", - global: pipelineProcessors{ - fields: common.MapStr{"global": 1, "host": common.MapStr{"name": "host123"}}, - }, - info: &beat.Info{ - Hostname: "test.host.hostname", - Name: "test.host.name", - }, - local: []local{ - { - config: beat.ClientConfig{}, - events: []common.MapStr{{"value": "abc", "host": common.MapStr{"hostname": "test.other.hostname"}}}, - expected: []common.MapStr{ - { - "host": common.MapStr{"name": "test.host.name", "hostname": "test.other.hostname"}, - "value": "abc", "global": 1, - }, - }, - includeHostName: true, - }, - }, - }, { name: "beat local fields", local: []local{ @@ -440,7 +393,6 @@ func TestProcessors(t *testing.T) { } for i, local := range test.local { local.config.SkipAgentMetadata = !local.includeAgentMetadata - local.config.SkipHostName = !local.includeHostName programs[i] = newProcessorPipeline(info, monitors, test.global, local.config) }