From 9539d656e61761c6ef5f1ef4462175bb3850954d Mon Sep 17 00:00:00 2001 From: vihas-splunk <121151420+vihas-splunk@users.noreply.github.com> Date: Fri, 24 Mar 2023 17:21:36 +0530 Subject: [PATCH] 1.3.2 (#273) --- Gemfile.lock | 14 +++++++------- README.md | 8 ++++++++ VERSION | 2 +- docker/Gemfile.lock | 2 +- lib/fluent/plugin/out_splunk_hec.rb | 7 ++++++- test/fluent/plugin/out_splunk_hec_test.rb | 7 +++++++ 6 files changed, 30 insertions(+), 10 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6c5e066..51f9566 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - fluent-plugin-splunk-hec (1.3.1) + fluent-plugin-splunk-hec (1.3.2) fluentd (>= 1.5) json-jwt (~> 1.15.0) multi_json (~> 1.13) @@ -13,9 +13,9 @@ PATH GEM remote: https://rubygems.org/ specs: - activemodel (7.0.4) - activesupport (= 7.0.4) - activesupport (7.0.4) + activemodel (7.0.4.3) + activesupport (= 7.0.4.3) + activesupport (7.0.4.3) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -25,7 +25,7 @@ GEM aes_key_wrap (1.1.0) attr_required (1.0.1) bindata (2.4.14) - concurrent-ruby (1.1.10) + concurrent-ruby (1.2.2) connection_pool (2.3.0) cool.io (1.7.1) crack (0.4.5) @@ -89,7 +89,7 @@ GEM power_assert (2.0.1) prometheus-client (4.0.0) public_suffix (4.0.6) - rack (3.0.1) + rack (3.0.6.1) rack-oauth2 (1.21.2) activesupport attr_required @@ -117,7 +117,7 @@ GEM test-unit (3.5.3) power_assert timeout (0.2.0) - tzinfo (2.0.5) + tzinfo (2.0.6) concurrent-ruby (~> 1.0) tzinfo-data (1.2022.6) tzinfo (>= 1.0.0) diff --git a/README.md b/README.md index 3b3612c..ddb4067 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +# End of Support + +**Important:** The fluent-plugin-splunk-hec will reach End of Support on January 1, 2024. After that date, this repository will no longer receive updates from Splunk and will no longer be supported by Splunk. Until then, only critical security fixes and bug fixes will be provided. + # fluent-plugin-splunk-hec [Fluentd](https://fluentd.org/) output plugin to send events and metrics to [Splunk](https://www.splunk.com) in 2 modes:
@@ -288,6 +292,10 @@ Splunk app name using this plugin (default to `hec_plugin_gem`) The version of Splunk app using this this plugin (default to plugin version) +### custom_headers (Hash) (Optional) + +Hash of custom headers to be added to the HTTP request. Used to populate [`override_headers`](https://docs.seattlerb.org/net-http-persistent/Net/HTTP/Persistent.html#attribute-i-override_headers) attribute of the underlying `Net::HTTP::Persistent` connection. + #### When `data_type` is `event` In this case, parameters inside `` are used as indexed fields and removed from the original input events. Please see the "Add a "fields" property at the top JSON level" [here](http://dev.splunk.com/view/event-collector/SP-CAAAFB6) for details. Given we have configuration like diff --git a/VERSION b/VERSION index 6261a05..d5e98f7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.3.1 \ No newline at end of file +1.3.2 \ No newline at end of file diff --git a/docker/Gemfile.lock b/docker/Gemfile.lock index 71835a4..0f608bc 100644 --- a/docker/Gemfile.lock +++ b/docker/Gemfile.lock @@ -12,7 +12,7 @@ GIT PATH remote: gem specs: - fluent-plugin-splunk-hec (1.3.1) + fluent-plugin-splunk-hec (1.3.2) fluentd (>= 1.5) json-jwt (~> 1.15.0) multi_json (~> 1.13) diff --git a/lib/fluent/plugin/out_splunk_hec.rb b/lib/fluent/plugin/out_splunk_hec.rb index a88900d..ee14b14 100644 --- a/lib/fluent/plugin/out_splunk_hec.rb +++ b/lib/fluent/plugin/out_splunk_hec.rb @@ -134,6 +134,9 @@ class SplunkHecOutput < SplunkOutput DESC config_param :non_utf8_replacement_string, :string, :default => ' ' + desc 'Any custom headers to include alongside requests made to Splunk' + config_param :custom_headers, :hash, :default => {} + def initialize super @default_host = Socket.gethostname @@ -168,7 +171,9 @@ def start c.override_headers['Authorization'] = "Splunk #{@hec_token}" c.override_headers['__splunk_app_name'] = "#{@app_name}" c.override_headers['__splunk_app_version'] = "#{@app_version}" - + @custom_headers.each do |header, value| + c.override_headers[header] = value + end end end diff --git a/test/fluent/plugin/out_splunk_hec_test.rb b/test/fluent/plugin/out_splunk_hec_test.rb index 3ecfb69..6d8b018 100644 --- a/test/fluent/plugin/out_splunk_hec_test.rb +++ b/test/fluent/plugin/out_splunk_hec_test.rb @@ -66,6 +66,13 @@ it 'should support enabling gzip' do expect(create_hec_output_driver('hec_host hec_token', 'gzip_compression true').instance.gzip_compression).must_equal true end + it 'should define custom_headers as {} (hash) initially' do + assert_empty(create_hec_output_driver('hec_host hec_token').instance.custom_headers) + expect(create_hec_output_driver('hec_host hec_token').instance.custom_headers).is_a? Hash + end + it 'should allow setting custom_headers' do + assert_equal(create_hec_output_driver('hec_host hec_token', 'custom_headers {"custom":"header"}').instance.custom_headers, {"custom" => "header"}) + end end describe 'hec_host validation' do