@@ -267,6 +267,78 @@ def test_emit_with_sumo_metadata_with_fields_fields_format
267267 times :1
268268 end
269269
270+ def test_emit_with_sumo_metadata_with_fields_and_custom_fields_fields_format
271+ config = %{
272+ endpoint https://collectors.sumologic.com/v1/receivers/http/1234
273+ log_format fields
274+ custom_fields "lorem=ipsum,dolor=amet"
275+ }
276+ driver = create_driver ( config )
277+ time = event_time
278+ stub_request ( :post , 'https://collectors.sumologic.com/v1/receivers/http/1234' )
279+ ENV [ 'HOST' ] = "foo"
280+ driver . run do
281+ driver . feed ( "output.test" , time , { 'foo' => 'shark' , 'message' => 'test' , '_sumo_metadata' => {
282+ "host" : "#{ ENV [ 'HOST' ] } " ,
283+ "source" : "${tag}" ,
284+ "category" : "test" ,
285+ "fields" : "foo=bar, sumo = logic"
286+ } } )
287+ end
288+ assert_requested :post , "https://collectors.sumologic.com/v1/receivers/http/1234" ,
289+ headers : { 'X-Sumo-Category' => 'test' , 'X-Sumo-Client' => 'fluentd-output' , 'X-Sumo-Host' => 'foo' , 'X-Sumo-Name' => 'output.test' , 'X-Sumo-Fields' => 'foo=bar, sumo = logic,lorem=ipsum,dolor=amet' } ,
290+ body : /\A {"timestamp":\d +.,"foo":"shark","message":"test"}\z / ,
291+ times :1
292+ end
293+
294+ def test_emit_with_sumo_metadata_with_fields_and_empty_custom_fields_fields_format
295+ config = %{
296+ endpoint https://collectors.sumologic.com/v1/receivers/http/1234
297+ log_format fields
298+ custom_fields ""
299+ }
300+ driver = create_driver ( config )
301+ time = event_time
302+ stub_request ( :post , 'https://collectors.sumologic.com/v1/receivers/http/1234' )
303+ ENV [ 'HOST' ] = "foo"
304+ driver . run do
305+ driver . feed ( "output.test" , time , { 'foo' => 'shark' , 'message' => 'test' , '_sumo_metadata' => {
306+ "host" : "#{ ENV [ 'HOST' ] } " ,
307+ "source" : "${tag}" ,
308+ "category" : "test" ,
309+ "fields" : "foo=bar, sumo = logic"
310+ } } )
311+ end
312+ assert_requested :post , "https://collectors.sumologic.com/v1/receivers/http/1234" ,
313+ headers : { 'X-Sumo-Category' => 'test' , 'X-Sumo-Client' => 'fluentd-output' , 'X-Sumo-Host' => 'foo' , 'X-Sumo-Name' => 'output.test' , 'X-Sumo-Fields' => 'foo=bar, sumo = logic' } ,
314+ body : /\A {"timestamp":\d +.,"foo":"shark","message":"test"}\z / ,
315+ times :1
316+ end
317+
318+ def test_emit_with_sumo_metadata_with_empty_fields_and_custom_fields_fields_format
319+ config = %{
320+ endpoint https://collectors.sumologic.com/v1/receivers/http/1234
321+ log_format fields
322+ custom_fields "lorem=ipsum"
323+ }
324+ driver = create_driver ( config )
325+ time = event_time
326+ stub_request ( :post , 'https://collectors.sumologic.com/v1/receivers/http/1234' )
327+ ENV [ 'HOST' ] = "foo"
328+ driver . run do
329+ driver . feed ( "output.test" , time , { 'foo' => 'shark' , 'message' => 'test' , '_sumo_metadata' => {
330+ "host" : "#{ ENV [ 'HOST' ] } " ,
331+ "source" : "${tag}" ,
332+ "category" : "test" ,
333+ "fields" : ""
334+ } } )
335+ end
336+ assert_requested :post , "https://collectors.sumologic.com/v1/receivers/http/1234" ,
337+ headers : { 'X-Sumo-Category' => 'test' , 'X-Sumo-Client' => 'fluentd-output' , 'X-Sumo-Host' => 'foo' , 'X-Sumo-Name' => 'output.test' , 'X-Sumo-Fields' => 'lorem=ipsum' } ,
338+ body : /\A {"timestamp":\d +.,"foo":"shark","message":"test"}\z / ,
339+ times :1
340+ end
341+
270342 def test_emit_with_sumo_metadata
271343 config = %{
272344 endpoint https://collectors.sumologic.com/v1/receivers/http/1234
0 commit comments