fluent-plugin-sumologic_output 1.7.1 → 1.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38f85777973860ce39f213613b943139ae0304be0b69e13b2b1cde495a08e2d5
4
- data.tar.gz: b4838ac669ee2ae899b06236d57a6cf01144370b9f19ae0fe56f900051058936
3
+ metadata.gz: c3bf755e8ecd488457805d948614c43b3657de815889dd341091d11f338ad995
4
+ data.tar.gz: 20163f7c5ac543a010e53fce506dbaed10bafe5d46830579a3101558f5b61fa4
5
5
  SHA512:
6
- metadata.gz: 604cc97685ba67fe6bbee0dd519b4228f66a4ca13ef721371cc8adb56d253f0a4f710ff1f00270675ce8e95526d951d22a4cc2ab0e03c17168fc7021d8c39c71
7
- data.tar.gz: 61ab2d7c22d5f41d17cf3a4427db0f4c352ee5863b47b40b960279262ef047a5203e8ef98af5626ec0951625b520382a1003db7f9a320b1b408ffd5f573d67c4
6
+ metadata.gz: 35cf3af9a561fd22e810dea880570007613b7cb9ae87307dd46ea3ff8d9e005b96c9ebf19f1aafd58b6ae4495509f51406b7788029f7fb26144f54b60f22370a
7
+ data.tar.gz: 6b5e6a13ed50d798c4c0f8225e771a2c5977373373aed316cbe1a5369a2af22aef56c86e474aefd6ca847e41c496c287a191c23c1224d2a49075794b420949e4
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "fluent-plugin-sumologic_output"
7
- gem.version = "1.7.1"
7
+ gem.version = "1.7.2"
8
8
  gem.authors = ["Steven Adams", "Frank Reno"]
9
9
  gem.email = ["stevezau@gmail.com", "frank.reno@me.com"]
10
10
  gem.description = %q{Output plugin to SumoLogic HTTP Endpoint}
@@ -293,6 +293,19 @@ class Fluent::Plugin::Sumologic < Fluent::Plugin::Output
293
293
  time.to_s.length == 13 ? time : time * 1000
294
294
  end
295
295
 
296
+ # Convert log to string and strip it
297
+ def log_to_str(log)
298
+ if log.is_a?(Array) or log.is_a?(Hash)
299
+ log = Yajl.dump(log)
300
+ end
301
+
302
+ unless log.nil?
303
+ log.strip!
304
+ end
305
+
306
+ return log
307
+ end
308
+
296
309
  # This method is called every flush interval. Write the buffer chunk
297
310
  def write(chunk)
298
311
  messages_list = {}
@@ -313,10 +326,7 @@ class Fluent::Plugin::Sumologic < Fluent::Plugin::Output
313
326
  when 'logs'
314
327
  case log_format
315
328
  when 'text'
316
- log = record[@log_key]
317
- unless log.nil?
318
- log.strip!
319
- end
329
+ log = log_to_str(record[@log_key])
320
330
  when 'json_merge'
321
331
  if @add_timestamp
322
332
  record = { @timestamp_key => sumo_timestamp(time) }.merge(record)
@@ -334,10 +344,7 @@ class Fluent::Plugin::Sumologic < Fluent::Plugin::Output
334
344
  log = dump_log(record)
335
345
  end
336
346
  when 'metrics'
337
- log = record[@log_key]
338
- unless log.nil?
339
- log.strip!
340
- end
347
+ log = log_to_str(record[@log_key])
341
348
  end
342
349
 
343
350
  unless log.nil?
@@ -671,4 +671,46 @@ class SumologicOutput < Test::Unit::TestCase
671
671
  times:1
672
672
  end
673
673
 
674
- end
674
+ def test_emit_text_from_array
675
+ config = %{
676
+ endpoint https://collectors.sumologic.com/v1/receivers/http/1234
677
+ log_format text
678
+ source_category test
679
+ source_host test
680
+ source_name test
681
+
682
+ }
683
+ driver = create_driver(config)
684
+ time = event_time
685
+ stub_request(:post, 'https://collectors.sumologic.com/v1/receivers/http/1234')
686
+ driver.run do
687
+ driver.feed("output.test", time, {'foo' => 'bar', 'message' => ['test', 'test2']})
688
+ end
689
+ assert_requested :post, "https://collectors.sumologic.com/v1/receivers/http/1234",
690
+ headers: {'X-Sumo-Category'=>'test', 'X-Sumo-Client'=>'fluentd-output', 'X-Sumo-Host'=>'test', 'X-Sumo-Name'=>'test'},
691
+ body: '["test","test2"]',
692
+ times:1
693
+ end
694
+
695
+ def test_emit_text_from_dict
696
+ config = %{
697
+ endpoint https://collectors.sumologic.com/v1/receivers/http/1234
698
+ log_format text
699
+ source_category test
700
+ source_host test
701
+ source_name test
702
+
703
+ }
704
+ driver = create_driver(config)
705
+ time = event_time
706
+ stub_request(:post, 'https://collectors.sumologic.com/v1/receivers/http/1234')
707
+ driver.run do
708
+ driver.feed("output.test", time, {'foo' => 'bar', 'message' => {'test': 'test2', 'test3': 'test4'}})
709
+ end
710
+ assert_requested :post, "https://collectors.sumologic.com/v1/receivers/http/1234",
711
+ headers: {'X-Sumo-Category'=>'test', 'X-Sumo-Client'=>'fluentd-output', 'X-Sumo-Host'=>'test', 'X-Sumo-Name'=>'test'},
712
+ body: '{"test":"test2","test3":"test4"}',
713
+ times:1
714
+ end
715
+
716
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-sumologic_output
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Adams
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-04-28 00:00:00.000000000 Z
12
+ date: 2020-11-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -134,8 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
134
  - !ruby/object:Gem::Version
135
135
  version: '0'
136
136
  requirements: []
137
- rubyforge_project:
138
- rubygems_version: 2.7.7
137
+ rubygems_version: 3.0.8
139
138
  signing_key:
140
139
  specification_version: 4
141
140
  summary: Output plugin to SumoLogic HTTP Endpoint