fluent-plugin-splunk-hec 1.2.8 → 1.2.9

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: 3404443a78707ec84c807cc959de100eefec4c7144f76b4587fa4c02580d300d
4
- data.tar.gz: '098eb708f6093e40c59aa597c7f185403f9fb195c03758a726ebd8bcc2fc4468'
3
+ metadata.gz: 3fbf155dc5649294d859dbdc4bc9967681f8d4051f93e7c108bf926961f93afe
4
+ data.tar.gz: 1bf76e9bb39b3bbf9dc0ae87f8ca38046cbe4f30a86ae0c6c6fef4be257fbb74
5
5
  SHA512:
6
- metadata.gz: b7dc521fe94e36ae9e4df51f5a32c936615228a164f76ec9391bd72033aa06d35e8292d8cc95b6025cf880943e56f48c2bebbbc5a9e606e219972528a464c9a3
7
- data.tar.gz: 4d6ae8221544453debf6e0dbf1ecbdb9a0774f36ae3d1e4715781ca078a2c0d3ebd2870455ffcd75bdb292d1634a8e71d6034f620c69638d51372f010cac4d46
6
+ metadata.gz: 5228076cb01aa5a32c77f7d532ecb7052f57366e2dbd9d5f1e3fcae1cb7d5ca042bec12393f4c760ce05c4205068473852fdf020255b45d20679af2ee623da85
7
+ data.tar.gz: 82a15c018c694133cb6e5d4891413ba272087f385586582ae5b00a91b78bc455918116ee078f52f5cc26f7440852c4f2549d1b1730f2c5f3480130896f7d6fe7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fluent-plugin-splunk-hec (1.2.8)
4
+ fluent-plugin-splunk-hec (1.2.9)
5
5
  fluentd (>= 1.4)
6
6
  multi_json (~> 1.13)
7
7
  net-http-persistent (~> 3.1)
@@ -131,4 +131,4 @@ DEPENDENCIES
131
131
  webmock (~> 3.5.0)
132
132
 
133
133
  BUNDLED WITH
134
- 2.2.30
134
+ 2.2.33
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.8
1
+ 1.2.9
@@ -193,8 +193,8 @@ module Fluent::Plugin
193
193
  v = instance_variable_get "@#{f}"
194
194
  next unless v
195
195
 
196
- if v == TAG_PLACEHOLDER
197
- instance_variable_set "@#{f}", ->(tag, _) { tag }
196
+ if v.include? TAG_PLACEHOLDER
197
+ instance_variable_set "@#{f}", ->(tag, _) { v.gsub(TAG_PLACEHOLDER, tag) }
198
198
  else
199
199
  instance_variable_set "@#{f}", ->(_, _) { v }
200
200
  end
@@ -31,13 +31,16 @@ module Fluent::Plugin
31
31
  config_param :protocol, :enum, list: %i[http https], default: :https
32
32
 
33
33
  desc 'The hostname/IP to HEC, or HEC load balancer.'
34
- config_param :hec_host, :string
34
+ config_param :hec_host, :string, default: ''
35
35
 
36
36
  desc 'The port number to HEC, or HEC load balancer.'
37
37
  config_param :hec_port, :integer, default: 8088
38
38
 
39
+ desc 'Full url to connect tosplunk. Example: https://mydomain.com:8088/apps/splunk'
40
+ config_param :full_url, :string, default: ''
41
+
39
42
  desc 'The HEC token.'
40
- config_param :hec_token, :string
43
+ config_param :hec_token, :string, secret: true
41
44
 
42
45
  desc 'If a connection has not been used for this number of seconds it will automatically be reset upon the next use to avoid attempting to send to a closed connection. nil means no timeout.'
43
46
  config_param :idle_timeout, :integer, default: 5
@@ -132,7 +135,7 @@ module Fluent::Plugin
132
135
 
133
136
  def configure(conf)
134
137
  super
135
-
138
+ raise Fluent::ConfigError, 'One of `hec_host` or `full_url` is required.' if @hec_host.empty? && @full_url.empty?
136
139
  check_metric_configs
137
140
  pick_custom_format_method
138
141
  end
@@ -279,9 +282,17 @@ module Fluent::Plugin
279
282
  end
280
283
 
281
284
  def construct_api
282
- URI("#{@protocol}://#{@hec_host}:#{@hec_port}/services/collector")
285
+ if @full_url.empty?
286
+ URI("#{@protocol}://#{@hec_host}:#{@hec_port}/services/collector")
287
+ else
288
+ URI("#{@full_url.delete_suffix("/")}/services/collector")
289
+ end
283
290
  rescue StandardError
284
- raise Fluent::ConfigError, "hec_host (#{@hec_host}) and/or hec_port (#{@hec_port}) are invalid."
291
+ if @full_url.empty?
292
+ raise Fluent::ConfigError, "hec_host (#{@hec_host}) and/or hec_port (#{@hec_port}) are invalid."
293
+ else
294
+ raise Fluent::ConfigError, "full_url (#{@full_url}) is invalid."
295
+ end
285
296
  end
286
297
 
287
298
  def new_connection
@@ -312,10 +323,13 @@ module Fluent::Plugin
312
323
  post.body = chunk.read
313
324
  log.debug { "[Sending] Chunk: #{dump_unique_id_hex(chunk.unique_id)}(#{post.body.bytesize}B)." }
314
325
  log.trace { "POST #{@api} body=#{post.body}" }
315
-
316
- t1 = Time.now
317
- response = @conn.request @api, post
318
- t2 = Time.now
326
+ begin
327
+ t1 = Time.now
328
+ response = @conn.request @api, post
329
+ t2 = Time.now
330
+ rescue Net::HTTP::Persistent::Error => e
331
+ raise e.cause
332
+ end
319
333
 
320
334
  raise_err = response.code.to_s.start_with?('5') || (!@consume_chunk_on_4xx_errors && response.code.to_s.start_with?('4'))
321
335
 
@@ -64,7 +64,7 @@ describe Fluent::Plugin::SplunkHecOutput do
64
64
 
65
65
  describe 'hec_host validation' do
66
66
  describe 'invalid host' do
67
- it 'should require hec_host' do
67
+ it 'should require hec_host or full_url' do
68
68
  expect { create_hec_output_driver }.must_raise Fluent::ConfigError
69
69
  end
70
70
 
@@ -78,6 +78,17 @@ describe Fluent::Plugin::SplunkHecOutput do
78
78
  end
79
79
  end
80
80
 
81
+ describe 'full_url validation' do
82
+ describe 'invalid full_url' do
83
+ it { expect { create_hec_output_driver(full_url: '%bad-host%.com') }.must_raise Fluent::ConfigError }
84
+ end
85
+ describe 'good full_url' do
86
+ it {
87
+ expect(create_hec_output_driver('full_url https://splunk.com').instance.full_url).must_equal 'https://splunk.com'
88
+ }
89
+ end
90
+ end
91
+
81
92
  it 'should send request to Splunk' do
82
93
  req = verify_sent_events do |batch|
83
94
  expect(batch.size).must_equal 2
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-splunk-hec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.8
4
+ version: 1.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Splunk Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-04 00:00:00.000000000 Z
11
+ date: 2021-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -222,12 +222,12 @@ specification_version: 4
222
222
  summary: Fluentd plugin for Splunk HEC.
223
223
  test_files:
224
224
  - test/test_helper.rb
225
- - test/fluent/plugin/out_splunk_hec_test.rb
226
- - test/fluent/plugin/out_splunk_ingest_api_test.rb
227
- - test/lib/webmock/http_lib_adapters/curb_adapter.rb
228
- - test/lib/webmock/http_lib_adapters/em_http_request_adapter.rb
225
+ - test/lib/webmock/http_lib_adapters/manticore_adapter.rb
229
226
  - test/lib/webmock/http_lib_adapters/http_rb_adapter.rb
230
227
  - test/lib/webmock/http_lib_adapters/typhoeus_hydra_adapter.rb
231
- - test/lib/webmock/http_lib_adapters/manticore_adapter.rb
228
+ - test/lib/webmock/http_lib_adapters/em_http_request_adapter.rb
232
229
  - test/lib/webmock/http_lib_adapters/excon_adapter.rb
230
+ - test/lib/webmock/http_lib_adapters/curb_adapter.rb
233
231
  - test/lib/webmock/http_lib_adapters/patron_adapter.rb
232
+ - test/fluent/plugin/out_splunk_ingest_api_test.rb
233
+ - test/fluent/plugin/out_splunk_hec_test.rb