fluent-plugin-out-http 1.1.0 → 1.1.1

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: 6c9b48a2a4c29d1c6a8e7178fbe20a8a5f008c62ee2e8c143462d1a87cfe8abb
4
- data.tar.gz: df8adcc79a9f7cadb17ea48884ca3c6505c45d09ea3cb8049cab53ed7d02624f
3
+ metadata.gz: 3880fd774a40aecbe2a66d70b82f1839262ac6b788a9beded2cd5209a272c9eb
4
+ data.tar.gz: f4edd620701fdba356062650b67fb80b45308d240d49240b291447cea10788d8
5
5
  SHA512:
6
- metadata.gz: fce02600476eddabc19b92fa08bc5ef555e3c90b459ec999c8fa9ec8290e490c1039d7bc51e1614f28c1bf9b4628c50ff734eeec515fd371af259138a4c6f1ff
7
- data.tar.gz: df0573593436717a393523cf7a10325e9d45dd72e04cb7ee7950c8871ffd6257b7ab4123942384cab33554657c48d7f8b8b17adbd932cf0aa65f9d2441f8442f
6
+ metadata.gz: 7596426626b5c0c419c5851075f9727b998c10a8ddfc65304ed9580a461d5b0fabb626de0dd19ff8dd951174afb8ee749e65127df08dafcb6b610843226948a0
7
+ data.tar.gz: 03bfe5f1164a42accc81b1fc2a0c746ad80b468d70e0b313994e86d5b2765ffad11cf4f14aecc51bc7e4412c46999dd88c9fe251053b2140627555fa3c94d0ef
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.1.1
4
+ * Added plain text transport capability
5
+ * Added specify cacert file for ssl verify
6
+
7
+ ## 1.1.0
8
+ * Support for jwt token authentication
9
+
10
+ ## 1.0.1
11
+ * Added endpoint_url placeholder support
12
+
13
+ ## 1.0.0
14
+ * Use Fluentd v1 API
15
+
3
16
  ## 0.2.0
4
17
  ### Added
5
18
  * SSL is now supported if `endpoint_url` uses the `https` scheme (uses ruby-2.1 syntax internally)
data/README.md CHANGED
@@ -17,6 +17,7 @@ A generic [fluentd][1] output plugin for sending logs to an HTTP endpoint.
17
17
  username alice # default: ''
18
18
  password bobpop # default: '', secret: true
19
19
  buffered true # default: false. Switch non-buffered/buffered mode
20
+ cacert_file /etc/ssl/endpoint1.cert # default: ''
20
21
  token tokent # default: ''
21
22
  </match>
22
23
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "fluent-plugin-out-http"
5
- gem.version = "1.1.0"
5
+ gem.version = "1.1.1"
6
6
  gem.authors = ["Marica Odagaki"]
7
7
  gem.email = ["ento.entotto@gmail.com"]
8
8
  gem.summary = %q{A generic Fluentd output plugin to send logs to an HTTP endpoint}
@@ -24,7 +24,7 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
24
24
  config_param :http_method, :enum, list: [:get, :put, :post, :delete], :default => :post
25
25
 
26
26
  # form | json
27
- config_param :serializer, :enum, list: [:json, :form], :default => :form
27
+ config_param :serializer, :enum, list: [:json, :form, :text], :default => :form
28
28
 
29
29
  # Simple rate limiting: ignore any records within `rate_limit_msec`
30
30
  # since the last one.
@@ -33,6 +33,9 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
33
33
  # Raise errors that were rescued during HTTP requests?
34
34
  config_param :raise_on_error, :bool, :default => true
35
35
 
36
+ # ca file to use for https request
37
+ config_param :cacert_file, :string, :default => ''
38
+
36
39
  # 'none' | 'basic' | 'jwt' | 'bearer'
37
40
  config_param :authentication, :enum, list: [:none, :basic, :jwt, :bearer], :default => :none
38
41
  config_param :username, :string, :default => ''
@@ -56,6 +59,7 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
56
59
  OpenSSL::SSL::VERIFY_PEER
57
60
  end
58
61
 
62
+ @ca_file = @cacert_file
59
63
  @last_request_time = nil
60
64
  raise Fluent::ConfigError, "'tag' in chunk_keys is required." if !@chunk_key_tag && @buffered
61
65
  end
@@ -75,6 +79,8 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
75
79
  def set_body(req, tag, time, record)
76
80
  if @serializer == :json
77
81
  set_json_body(req, record)
82
+ elsif @serializer == :text
83
+ set_text_body(req, record)
78
84
  else
79
85
  req.set_form_data(record)
80
86
  end
@@ -90,6 +96,11 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
90
96
  req['Content-Type'] = 'application/json'
91
97
  end
92
98
 
99
+ def set_text_body(req, data)
100
+ req.body = data["message"]
101
+ req['Content-Type'] = 'text/plain'
102
+ end
103
+
93
104
  def create_request(tag, time, record)
94
105
  url = format_url(tag, time, record)
95
106
  uri = URI.parse(url)
@@ -104,6 +115,7 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
104
115
  :use_ssl => uri.scheme == 'https'
105
116
  }
106
117
  opts[:verify_mode] = @ssl_verify_mode if opts[:use_ssl]
118
+ opts[:ca_file] = File.join(@ca_file) if File.file?(@ca_file)
107
119
  opts
108
120
  end
109
121
 
@@ -96,6 +96,9 @@ class HTTPOutputTestBase < Test::Unit::TestCase
96
96
  record = {:auth => nil}
97
97
  if req.content_type == 'application/json'
98
98
  record[:json] = Yajl.load(req.body)
99
+ elsif req.content_type == 'text/plain'
100
+ puts req
101
+ record[:data] = req.body
99
102
  else
100
103
  record[:form] = Hash[*(req.body.split('&').map{|kv|kv.split('=')}.flatten)]
101
104
  end
@@ -202,6 +205,11 @@ class HTTPOutputTest < HTTPOutputTestBase
202
205
  serializer json
203
206
  ]
204
207
 
208
+ CONFIG_TEXT = %[
209
+ endpoint_url http://127.0.0.1:#{port}/api/
210
+ serializer text
211
+ ]
212
+
205
213
  CONFIG_PUT = %[
206
214
  endpoint_url http://127.0.0.1:#{port}/api/
207
215
  http_method put
@@ -390,6 +398,18 @@ class HTTPOutputTest < HTTPOutputTestBase
390
398
  assert_nil record[:auth]
391
399
  end
392
400
 
401
+ def test_emit_text
402
+ binary_string = "\xe3\x81\x82"
403
+ d = create_driver CONFIG_TEXT
404
+ d.run(default_tag: 'test.metrics') do
405
+ d.feed({ "message" => "hello" })
406
+ end
407
+ assert_equal 1, @posts.size
408
+ record = @posts[0]
409
+ assert_equal 'hello', record[:data]
410
+ assert_nil record[:auth]
411
+ end
412
+
393
413
  def test_http_error_is_raised
394
414
  d = create_driver CONFIG_HTTP_ERROR
395
415
  assert_raise Errno::ECONNREFUSED do
@@ -542,6 +562,20 @@ class HTTPSOutputTest < HTTPOutputTestBase
542
562
  http_opts = d.instance.http_opts(test_uri)
543
563
  assert_equal true, http_opts[:use_ssl]
544
564
  assert_equal OpenSSL::SSL::VERIFY_NONE, http_opts[:verify_mode]
565
+
566
+ cacert_file_config = %[
567
+ endpoint_url https://127.0.0.1:#{self.class.port}/api/
568
+ ssl_no_verify true
569
+ cacert_file /tmp/ssl.cert
570
+ ]
571
+ d = create_driver cacert_file_config
572
+ FileUtils::touch '/tmp/ssl.cert'
573
+ http_opts = d.instance.http_opts(test_uri)
574
+ assert_equal true, http_opts[:use_ssl]
575
+ assert_equal OpenSSL::SSL::VERIFY_NONE, http_opts[:verify_mode]
576
+ assert_equal true, File.file?('/tmp/ssl.cert')
577
+ puts http_opts
578
+ assert_equal File.join('/tmp/ssl.cert'), http_opts[:ca_file]
545
579
  end
546
580
 
547
581
  def test_emit_form_ssl
@@ -559,4 +593,21 @@ class HTTPSOutputTest < HTTPOutputTestBase
559
593
 
560
594
  assert_equal '50', record[:form]['field1']
561
595
  end
596
+
597
+ def test_emit_form_ssl_ca
598
+ config = %[
599
+ endpoint_url https://127.0.0.1:#{self.class.port}/api/
600
+ ssl_no_verify true
601
+ cacert_file /tmp/ssl.cert
602
+ ]
603
+ d = create_driver config
604
+ d.run(default_tag: 'test.metrics') do
605
+ d.feed({ 'field1' => 50 })
606
+ end
607
+
608
+ assert_equal 1, @posts.size
609
+ record = @posts[0]
610
+
611
+ assert_equal '50', record[:form]['field1']
612
+ end
562
613
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-out-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marica Odagaki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-07 00:00:00.000000000 Z
11
+ date: 2018-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yajl-ruby