fluent-plugin-sumologic_output 1.7.3 → 1.7.4

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: 52b0c77e900d61ba360421933440383208033b29b0f08b012250519189872f24
4
- data.tar.gz: ff86f952744e650e30ba94d1185f4d270a3d8d6e7bfee5f30a0810e043a9483f
3
+ metadata.gz: 8ecb31a6366d5d0d352759cd11053747029c07d65267d410c5dfb4826b487ad8
4
+ data.tar.gz: 43b5911ccfeecd4e9d5a3f56b040678fb5e089a1793668b61559544e73427697
5
5
  SHA512:
6
- metadata.gz: 74c43d262f35e2767d170a05dbec58911590c0851a724f6c4adb0047a26601383e4d8fa5e2671c845bbd89a65781fb0d35e4bc2f8d7ed6bd0f0e376d6c7ec958
7
- data.tar.gz: 73b8ea2a6dbf4593eca7d4a702eeea14f27728bd7aa28ddc15e968301a5a2eb21f76ae18f1be2dd759f42cb357c2ceda92aec49e136755d76c954ebded889cdd
6
+ metadata.gz: 590654de132ef18f36d6ef3671e7fec0a6b813c7e23beb2c602fd259521e405ef043cdefd2ba96b6454c72d91d88e9be9b3baa89467893c9448e36003a09655b
7
+ data.tar.gz: 0ab2c898106c02e8cb01af1f34231d230528378dd71173c569521be35c5b8427951f0219ff049b114f912d9fc2e92924b9023159c2fd187425cbf7b16fccd4e0
data/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
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.7.3"></a>
6
+ # [1.7.3] (2021-10-19)
7
+ - Expose httpclient send_timeout [#66](https://github.com/SumoLogic/fluentd-output-sumologic/pull/68)
8
+ - Fix json parsing [#69](https://github.com/SumoLogic/fluentd-output-sumologic/pull/69)
9
+
10
+ <a name="1.7.2"></a>
11
+ # [1.7.2] (2020-11-23)
12
+ - Fix configuration for older fluentd versions [#63](https://github.com/SumoLogic/fluentd-output-sumologic/pull/63)
13
+
5
14
  <a name="1.7.1"></a>
6
15
  # [1.7.1] (2020-04-28)
7
16
  - Fix configuration for older fluentd versions [#63](https://github.com/SumoLogic/fluentd-output-sumologic/pull/63)
@@ -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.3"
7
+ gem.version = "1.7.4"
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}
@@ -13,12 +13,13 @@ class SumologicConnection
13
13
  COMPRESS_DEFLATE = 'deflate'
14
14
  COMPRESS_GZIP = 'gzip'
15
15
 
16
- def initialize(endpoint, verify_ssl, connect_timeout, send_timeout, proxy_uri, disable_cookies, sumo_client, compress_enabled, compress_encoding)
16
+ def initialize(endpoint, verify_ssl, connect_timeout, send_timeout, proxy_uri, disable_cookies, sumo_client, compress_enabled, compress_encoding, logger)
17
17
  @endpoint = endpoint
18
18
  @sumo_client = sumo_client
19
19
  create_http_client(verify_ssl, connect_timeout, send_timeout, proxy_uri, disable_cookies)
20
20
  @compress = compress_enabled
21
21
  @compress_encoding = (compress_encoding ||= COMPRESS_GZIP).downcase
22
+ @logger = logger
22
23
 
23
24
  unless [COMPRESS_DEFLATE, COMPRESS_GZIP].include? @compress_encoding
24
25
  raise "Invalid compression encoding #{@compress_encoding} must be gzip or deflate"
@@ -30,6 +31,29 @@ class SumologicConnection
30
31
  unless response.ok?
31
32
  raise RuntimeError, "Failed to send data to HTTP Source. #{response.code} - #{response.body}"
32
33
  end
34
+
35
+ # response is 20x, check response content
36
+ return if response.content.length == 0
37
+
38
+ # if we get a non-empty response, check it
39
+ begin
40
+ response_map = JSON.load(response.content)
41
+ rescue JSON::ParserError
42
+ @logger.warn "Error decoding receiver response: #{response.content}"
43
+ return
44
+ end
45
+
46
+ # log a warning with the present keys
47
+ response_keys = ["id", "code", "status", "message", "errors"]
48
+ log_params = []
49
+ response_keys.each do |key|
50
+ if response_map.has_key?(key) then
51
+ value = response_map[key]
52
+ log_params.append("#{key}: #{value}")
53
+ end
54
+ end
55
+ log_params_str = log_params.join(", ")
56
+ @logger.warn "There was an issue sending data: #{log_params_str}"
33
57
  end
34
58
 
35
59
  def request_headers(source_host, source_category, source_name, data_type, metric_data_format, collected_fields, dimensions)
@@ -218,7 +242,8 @@ class Fluent::Plugin::Sumologic < Fluent::Plugin::Output
218
242
  conf['disable_cookies'],
219
243
  conf['sumo_client'],
220
244
  conf['compress'],
221
- conf['compress_encoding']
245
+ conf['compress_encoding'],
246
+ log,
222
247
  )
223
248
  super
224
249
  end
@@ -795,6 +795,34 @@ class SumologicOutput < Test::Unit::TestCase
795
795
  headers: {'X-Sumo-Category'=>'test', 'X-Sumo-Client'=>'fluentd-output', 'X-Sumo-Host'=>'test', 'X-Sumo-Name'=>'test'},
796
796
  body: /\A{"timestamp":\d+.,"message":"\\"foo\\\\\\": \\\\\\"bar\\\\\\", \\\\\\"mess"}\z/,
797
797
  times:1
798
- end
798
+ end
799
+
800
+ def test_warning_response_from_receiver
801
+ endpoint = "https://collectors.sumologic.com/v1/receivers/http/1234"
802
+ config = %{
803
+ endpoint #{endpoint}
804
+ }
805
+ testdata = [
806
+ [
807
+ '{"id":"1TIRY-KGIVX-TPQRJ","errors":[{"code":"internal.error","message":"Internal server error."}]}',
808
+ 'There was an issue sending data: id: 1TIRY-KGIVX-TPQRJ, errors: [{"code"=>"internal.error", "message"=>"Internal server error."}]'
809
+ ],
810
+ [
811
+ '{"id":"1TIRY-KGIVX-TPQRX","code": 200, "status": "Fields dropped", "message": "Dropped fields above the 30 field limit"}',
812
+ 'There was an issue sending data: id: 1TIRY-KGIVX-TPQRX, code: 200, status: Fields dropped, message: Dropped fields above the 30 field limit'
813
+ ],
814
+ ]
815
+ time = event_time
816
+
817
+ testdata.each do |data, log|
818
+ driver = create_driver(config)
819
+ stub_request(:post, endpoint).to_return(body: data, headers: {content_type: 'application/json'})
820
+ driver.run do
821
+ driver.feed("test", time, {"message": "test"})
822
+ end
823
+ assert_equal driver.logs.length, 1
824
+ assert driver.logs[0].end_with?(log + "\n")
825
+ end
826
+ end
799
827
 
800
828
  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.3
4
+ version: 1.7.4
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: 2021-10-19 00:00:00.000000000 Z
12
+ date: 2022-04-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler