fluent-plugin-sumologic_output 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6db47bbad47c3eb7ea578b1e894ddc972336e785c94bb8af47595481b7e934e2
4
- data.tar.gz: 3457257200adc1b655ed1820a5041e29c22531e621aa24a6dd620105ac4559f1
3
+ metadata.gz: 133846d8832ef986550e20aa4d830f1b38c22528398ed4ef589af16cf553be2e
4
+ data.tar.gz: 6dde4d581727f2c6703b0e31d1907b935f53dd744b2b133ba36ca8ba437338c2
5
5
  SHA512:
6
- metadata.gz: cad8b409225fdd0d96402c17a950c0fb67ad61d0f28ac98a252bac23671cee9a3152738c37f916295c116c0396ede9ea874339c8d4278daf81f698060b56f63d
7
- data.tar.gz: 619b7cc028a11d1485b158a08e5f34f00440e5410b14b4283d0dda778f80d22944be9f753275a3028c360e15a69baf437b761a09c7e6b29e2f2c784bf3c0d965
6
+ metadata.gz: d9f7bb3b6a59030a406eaac3c69568f03c98c4dd00578f1a089687e7d8e7d2f2a5e3f1ce7d76eaecda0ea26a8dd4519f0ee8ea2533b85bcdc9f75fdca0b703f0
7
+ data.tar.gz: 0d7074aeb0dfcca743cce825690e4b5fd03f3c13e01df0bfb94b85762639747d51b1c7434aa15b84ea83db790507fd058b16098ec01f42eb6ce236dca57407c2
data/CHANGELOG.md CHANGED
@@ -2,7 +2,11 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. Tracking did not begin until version 1.10.
4
4
 
5
- <a name="1.4.0"></a>
5
+ <a name="1.5.0"></a>
6
+ # [1.5.0] (2019-06-26)
7
+ - Add support for new log format fields: [#49](https://github.com/SumoLogic/fluentd-output-sumologic/pull/49)
8
+
9
+ <a name="1.4.1"></a>
6
10
  # [1.4.1] (2019-03-13)
7
11
 
8
12
  - Add option for sending metrics in Prometheus format [#39](https://github.com/SumoLogic/fluentd-output-sumologic/pull/39)
@@ -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.5.0"
7
+ gem.version = "1.6.0"
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}
@@ -195,7 +195,10 @@ class Fluent::Plugin::Sumologic < Fluent::Plugin::Output
195
195
  source_host = sumo_metadata['host'] || @source_host
196
196
  source_host = extract_placeholders(source_host, chunk) unless source_host.nil?
197
197
 
198
- "#{source_name}:#{source_category}:#{source_host}"
198
+ fields = sumo_metadata['fields'] || ""
199
+ fields = extract_placeholders(fields, chunk) unless fields.nil?
200
+
201
+ "#{source_name}:#{source_category}:#{source_host}:#{fields}"
199
202
  end
200
203
 
201
204
  # Convert timestamp to 13 digit epoch if necessary
@@ -203,28 +206,9 @@ class Fluent::Plugin::Sumologic < Fluent::Plugin::Output
203
206
  time.to_s.length == 13 ? time : time * 1000
204
207
  end
205
208
 
206
- def sumo_fields(sumo_metadata)
207
- fields = sumo_metadata['fields'] || ""
208
- Hash[
209
- fields.split(',').map do |pair|
210
- k, v = pair.split('=', 2)
211
- [k, v]
212
- end
213
- ]
214
- end
215
-
216
- def dump_collected_fields(log_fields)
217
- if log_fields.nil?
218
- log_fields
219
- else
220
- log_fields.map{|k,v| "#{k}=#{v}"}.join(',')
221
- end
222
- end
223
-
224
209
  # This method is called every flush interval. Write the buffer chunk
225
210
  def write(chunk)
226
211
  messages_list = {}
227
- log_fields = nil
228
212
 
229
213
  # Sort messages
230
214
  chunk.msgpack_each do |time, record|
@@ -252,7 +236,6 @@ class Fluent::Plugin::Sumologic < Fluent::Plugin::Output
252
236
  end
253
237
  log = dump_log(merge_json(record))
254
238
  when 'fields'
255
- log_fields = sumo_fields(sumo_metadata)
256
239
  if @add_timestamp
257
240
  record = { @timestamp_key => sumo_timestamp(time) }.merge(record)
258
241
  end
@@ -282,7 +265,7 @@ class Fluent::Plugin::Sumologic < Fluent::Plugin::Output
282
265
 
283
266
  # Push logs to sumo
284
267
  messages_list.each do |key, messages|
285
- source_name, source_category, source_host = key.split(':')
268
+ source_name, source_category, source_host, fields = key.split(':')
286
269
  @sumo_conn.publish(
287
270
  messages.join("\n"),
288
271
  source_host =source_host,
@@ -290,7 +273,7 @@ class Fluent::Plugin::Sumologic < Fluent::Plugin::Output
290
273
  source_name =source_name,
291
274
  data_type =@data_type,
292
275
  metric_data_format =@metric_data_format,
293
- collected_fields =dump_collected_fields(log_fields)
276
+ collected_fields =fields
294
277
  )
295
278
  end
296
279
 
@@ -394,4 +394,85 @@ class SumologicOutput < Test::Unit::TestCase
394
394
  times:1
395
395
  end
396
396
 
397
+ def test_batching_same_headers
398
+ config = %{
399
+ endpoint https://collectors.sumologic.com/v1/receivers/http/1234
400
+ log_format json
401
+ source_category test
402
+ source_host test
403
+ source_name test
404
+ }
405
+ driver = create_driver(config)
406
+ time = event_time
407
+ stub_request(:post, 'https://collectors.sumologic.com/v1/receivers/http/1234')
408
+ driver.run do
409
+ driver.feed("output.test", time, {'message' => 'test1'})
410
+ driver.feed("output.test", time, {'message' => 'test2'})
411
+ end
412
+ assert_requested :post, "https://collectors.sumologic.com/v1/receivers/http/1234",
413
+ headers: {'X-Sumo-Category'=>'test', 'X-Sumo-Client'=>'fluentd-output', 'X-Sumo-Host'=>'test', 'X-Sumo-Name'=>'test'},
414
+ body: /\A{"timestamp":\d+.,"message":"test1"}\n{"timestamp":\d+.,"message":"test2"}\z/,
415
+ times:1
416
+ end
417
+
418
+ def test_batching_different_headers
419
+ config = %{
420
+ endpoint https://collectors.sumologic.com/v1/receivers/http/1234
421
+ log_format json
422
+ source_category test
423
+ source_host test
424
+ source_name test
425
+ }
426
+ driver = create_driver(config)
427
+ time = event_time
428
+ stub_request(:post, 'https://collectors.sumologic.com/v1/receivers/http/1234')
429
+ driver.run do
430
+ driver.feed("output.test", time, {'message' => 'test1', '_sumo_metadata' => {"category": "cat1"}})
431
+ driver.feed("output.test", time, {'message' => 'test2', '_sumo_metadata' => {"category": "cat2"}})
432
+ end
433
+ assert_requested :post, "https://collectors.sumologic.com/v1/receivers/http/1234",
434
+ headers: {'X-Sumo-Category'=>'cat1', 'X-Sumo-Client'=>'fluentd-output', 'X-Sumo-Host'=>'test', 'X-Sumo-Name'=>'test'},
435
+ body: /\A{"timestamp":\d+.,"message":"test1"}\z/,
436
+ times:1
437
+ assert_requested :post, "https://collectors.sumologic.com/v1/receivers/http/1234",
438
+ headers: {'X-Sumo-Category'=>'cat2', 'X-Sumo-Client'=>'fluentd-output', 'X-Sumo-Host'=>'test', 'X-Sumo-Name'=>'test'},
439
+ body: /\A{"timestamp":\d+.,"message":"test2"}\z/,
440
+ times:1
441
+ end
442
+
443
+ def test_batching_different_fields
444
+ config = %{
445
+ endpoint https://collectors.sumologic.com/v1/receivers/http/1234
446
+ log_format fields
447
+ source_category test
448
+ source_host test
449
+ source_name test
450
+ }
451
+ driver = create_driver(config)
452
+ time = event_time
453
+ stub_request(:post, 'https://collectors.sumologic.com/v1/receivers/http/1234')
454
+ driver.run do
455
+ driver.feed("output.test", time, {'message' => 'test1'})
456
+ driver.feed("output.test", time, {'message' => 'test2', '_sumo_metadata' => {"fields": "foo=bar"}})
457
+ driver.feed("output.test", time, {'message' => 'test3', '_sumo_metadata' => {"fields": "foo=bar,sumo=logic"}})
458
+ driver.feed("output.test", time, {'message' => 'test4', '_sumo_metadata' => {"fields": "foo=bar,abc=123"}})
459
+ end
460
+ assert_requested :post, "https://collectors.sumologic.com/v1/receivers/http/1234",
461
+ headers: {'X-Sumo-Category'=>'test', 'X-Sumo-Client'=>'fluentd-output', 'X-Sumo-Host'=>'test', 'X-Sumo-Name'=>'test'},
462
+ body: /\A{"timestamp":\d+.,"message":"test1"}\z/,
463
+ times:1
464
+ assert_requested :post, "https://collectors.sumologic.com/v1/receivers/http/1234",
465
+ headers: {'X-Sumo-Category'=>'test', 'X-Sumo-Client'=>'fluentd-output', 'X-Sumo-Host'=>'test', 'X-Sumo-Name'=>'test', 'X-Sumo-Fields' => 'foo=bar'},
466
+ body: /\A{"timestamp":\d+.,"message":"test2"}\z/,
467
+ times:1
468
+ assert_requested :post, "https://collectors.sumologic.com/v1/receivers/http/1234",
469
+ headers: {'X-Sumo-Category'=>'test', 'X-Sumo-Client'=>'fluentd-output', 'X-Sumo-Host'=>'test', 'X-Sumo-Name'=>'test', 'X-Sumo-Fields' => 'foo=bar,sumo=logic'},
470
+ body: /\A{"timestamp":\d+.,"message":"test3"}\z/,
471
+ times:1
472
+ assert_requested :post, "https://collectors.sumologic.com/v1/receivers/http/1234",
473
+ headers: {'X-Sumo-Category'=>'test', 'X-Sumo-Client'=>'fluentd-output', 'X-Sumo-Host'=>'test', 'X-Sumo-Name'=>'test', 'X-Sumo-Fields' => 'foo=bar,abc=123'},
474
+ body: /\A{"timestamp":\d+.,"message":"test4"}\z/,
475
+ times:1
476
+ end
477
+
397
478
  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.5.0
4
+ version: 1.6.0
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: 2019-06-26 00:00:00.000000000 Z
12
+ date: 2019-10-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -134,7 +134,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
134
134
  - !ruby/object:Gem::Version
135
135
  version: '0'
136
136
  requirements: []
137
- rubygems_version: 3.0.4
137
+ rubyforge_project:
138
+ rubygems_version: 2.7.7
138
139
  signing_key:
139
140
  specification_version: 4
140
141
  summary: Output plugin to SumoLogic HTTP Endpoint