@@ -38,6 +38,7 @@ func TestProcessors(t *testing.T) {
3838 events []common.MapStr
3939 expected []common.MapStr
4040 includeAgentMetadata bool
41+ includeHostName bool
4142 }
4243
4344 tests := []struct {
@@ -148,6 +149,52 @@ func TestProcessors(t *testing.T) {
148149 },
149150 },
150151 },
152+ {
153+ name : "add host name" ,
154+ global : pipelineProcessors {
155+ fields : common.MapStr {"global" : 1 , "host" : common.MapStr {"name" : "host123" }},
156+ },
157+ info : & beat.Info {
158+ Hostname : "test.host.hostname" ,
159+ Name : "test.host.name" ,
160+ },
161+ local : []local {
162+ {
163+ config : beat.ClientConfig {},
164+ events : []common.MapStr {{"value" : "abc" }},
165+ expected : []common.MapStr {
166+ {
167+ "host" : common.MapStr {"name" : "test.host.name" },
168+ "value" : "abc" , "global" : 1 ,
169+ },
170+ },
171+ includeHostName : true ,
172+ },
173+ },
174+ },
175+ {
176+ name : "add host name to existing host" ,
177+ global : pipelineProcessors {
178+ fields : common.MapStr {"global" : 1 , "host" : common.MapStr {"name" : "host123" }},
179+ },
180+ info : & beat.Info {
181+ Hostname : "test.host.hostname" ,
182+ Name : "test.host.name" ,
183+ },
184+ local : []local {
185+ {
186+ config : beat.ClientConfig {},
187+ events : []common.MapStr {{"value" : "abc" , "host" : common.MapStr {"hostname" : "test.other.hostname" }}},
188+ expected : []common.MapStr {
189+ {
190+ "host" : common.MapStr {"name" : "test.host.name" , "hostname" : "test.other.hostname" },
191+ "value" : "abc" , "global" : 1 ,
192+ },
193+ },
194+ includeHostName : true ,
195+ },
196+ },
197+ },
151198 {
152199 name : "beat local fields" ,
153200 local : []local {
@@ -393,6 +440,7 @@ func TestProcessors(t *testing.T) {
393440 }
394441 for i , local := range test .local {
395442 local .config .SkipAgentMetadata = ! local .includeAgentMetadata
443+ local .config .SkipHostName = ! local .includeHostName
396444 programs [i ] = newProcessorPipeline (info , monitors , test .global , local .config )
397445 }
398446
0 commit comments