fluent-plugin-out-http 0.3.0 → 0.3.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 +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +1 -0
- data/fluent-plugin-out-http.gemspec +1 -1
- data/lib/fluent/plugin/out_http.rb +15 -2
- data/test/plugin/test_out_http.rb +49 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3dfa31c31f15188b9975d34a9997f4ec9a5d2d7faa3d5a159689ab7f6e643f2
|
4
|
+
data.tar.gz: a33cf636b0f25ff45d8920de78c454eec77958e41fffd76adfd07e2b1cd0da53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02bfa51bd6026ee1370bc296a290002f85b6209361fa8707c0b065a7111c1d02bc36d78a43b498f36672454c4ee87bd789011dd07e049981ae4ed2a7e2dbe664
|
7
|
+
data.tar.gz: f5dd4c2646dfb524a14ef17db5d35858b4652ea15f7482a928f616a68936d7a0b222390e31094a9d9036b3f7e1f8ceaca6ab6e7811e87d27fb5764389e3d44bf
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.3.1
|
4
|
+
### Added
|
5
|
+
* Added plain text transport capability
|
6
|
+
* Added specify cacert file for ssl verify
|
7
|
+
|
8
|
+
## 0.3.0
|
9
|
+
### Added
|
10
|
+
* Support for jwt token authentication:
|
11
|
+
|
3
12
|
## 0.2.0
|
4
13
|
### Added
|
5
14
|
* SSL is now supported if `endpoint_url` uses the `https` scheme (uses ruby-2.1 syntax internally)
|
data/README.md
CHANGED
@@ -16,6 +16,7 @@ A generic [fluentd][1] output plugin for sending logs to an HTTP endpoint.
|
|
16
16
|
authentication basic # default: none
|
17
17
|
username alice # default: ''
|
18
18
|
password bobpop # default: '', secret: true
|
19
|
+
cacert_file /etc/ssl/endpoint1.cert # default: ''
|
19
20
|
token tokent # default: ''
|
20
21
|
</match>
|
21
22
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = "fluent-plugin-out-http"
|
5
|
-
gem.version = "0.3.
|
5
|
+
gem.version = "0.3.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}
|
@@ -27,6 +27,9 @@ class Fluent::HTTPOutput < Fluent::Output
|
|
27
27
|
# Raise errors that were rescued during HTTP requests?
|
28
28
|
config_param :raise_on_error, :bool, :default => true
|
29
29
|
|
30
|
+
# ca file to use for https request
|
31
|
+
config_param :cacert_file, :string, :default => ''
|
32
|
+
|
30
33
|
# nil | 'none' | 'basic' | 'jwt' | 'bearer'
|
31
34
|
config_param :authentication, :string, :default => nil
|
32
35
|
config_param :username, :string, :default => ''
|
@@ -42,7 +45,9 @@ class Fluent::HTTPOutput < Fluent::Output
|
|
42
45
|
OpenSSL::SSL::VERIFY_PEER
|
43
46
|
end
|
44
47
|
|
45
|
-
|
48
|
+
@ca_file = @cacert_file
|
49
|
+
|
50
|
+
serializers = [:json, :form, :text]
|
46
51
|
@serializer = if serializers.include? @serializer.intern
|
47
52
|
@serializer.intern
|
48
53
|
else
|
@@ -74,7 +79,7 @@ class Fluent::HTTPOutput < Fluent::Output
|
|
74
79
|
def shutdown
|
75
80
|
super
|
76
81
|
end
|
77
|
-
|
82
|
+
|
78
83
|
def format_url(tag, time, record)
|
79
84
|
@endpoint_url
|
80
85
|
end
|
@@ -82,6 +87,8 @@ class Fluent::HTTPOutput < Fluent::Output
|
|
82
87
|
def set_body(req, tag, time, record)
|
83
88
|
if @serializer == :json
|
84
89
|
set_json_body(req, record)
|
90
|
+
elsif @serializer == :text
|
91
|
+
set_text_body(req, record)
|
85
92
|
else
|
86
93
|
req.set_form_data(record)
|
87
94
|
end
|
@@ -97,6 +104,11 @@ class Fluent::HTTPOutput < Fluent::Output
|
|
97
104
|
req['Content-Type'] = 'application/json'
|
98
105
|
end
|
99
106
|
|
107
|
+
def set_text_body(req, data)
|
108
|
+
req.body = data["message"]
|
109
|
+
req['Content-Type'] = 'text/plain'
|
110
|
+
end
|
111
|
+
|
100
112
|
def create_request(tag, time, record)
|
101
113
|
url = format_url(tag, time, record)
|
102
114
|
uri = URI.parse(url)
|
@@ -111,6 +123,7 @@ class Fluent::HTTPOutput < Fluent::Output
|
|
111
123
|
:use_ssl => uri.scheme == 'https'
|
112
124
|
}
|
113
125
|
opts[:verify_mode] = @ssl_verify_mode if opts[:use_ssl]
|
126
|
+
opts[:ca_file] = File.join(@ca_file) if File.file?(@ca_file)
|
114
127
|
opts
|
115
128
|
end
|
116
129
|
|
@@ -92,6 +92,9 @@ class HTTPOutputTestBase < Test::Unit::TestCase
|
|
92
92
|
record = {:auth => nil}
|
93
93
|
if req.content_type == 'application/json'
|
94
94
|
record[:json] = Yajl.load(req.body)
|
95
|
+
elsif req.content_type == 'text/plain'
|
96
|
+
puts req
|
97
|
+
record[:data] = req.body
|
95
98
|
else
|
96
99
|
record[:form] = Hash[*(req.body.split('&').map{|kv|kv.split('=')}.flatten)]
|
97
100
|
end
|
@@ -192,6 +195,11 @@ class HTTPOutputTest < HTTPOutputTestBase
|
|
192
195
|
serializer json
|
193
196
|
]
|
194
197
|
|
198
|
+
CONFIG_TEXT = %[
|
199
|
+
endpoint_url http://127.0.0.1:#{port}/api/
|
200
|
+
serializer text
|
201
|
+
]
|
202
|
+
|
195
203
|
CONFIG_PUT = %[
|
196
204
|
endpoint_url http://127.0.0.1:#{port}/api/
|
197
205
|
http_method put
|
@@ -278,6 +286,17 @@ class HTTPOutputTest < HTTPOutputTestBase
|
|
278
286
|
assert_equal 1, record[:json]['otherfield']
|
279
287
|
assert_equal binary_string, record[:json]['binary']
|
280
288
|
assert_nil record[:auth]
|
289
|
+
end
|
290
|
+
|
291
|
+
def test_emit_text
|
292
|
+
binary_string = "\xe3\x81\x82"
|
293
|
+
d = create_driver CONFIG_TEXT
|
294
|
+
d.emit({ "message" => "hello" })
|
295
|
+
d.run
|
296
|
+
assert_equal 1, @posts.size
|
297
|
+
record = @posts[0]
|
298
|
+
assert_equal 'hello', record[:data]
|
299
|
+
assert_nil record[:auth]
|
281
300
|
end
|
282
301
|
|
283
302
|
def test_http_error_is_raised
|
@@ -422,6 +441,20 @@ class HTTPSOutputTest < HTTPOutputTestBase
|
|
422
441
|
http_opts = d.instance.http_opts(test_uri)
|
423
442
|
assert_equal true, http_opts[:use_ssl]
|
424
443
|
assert_equal OpenSSL::SSL::VERIFY_NONE, http_opts[:verify_mode]
|
444
|
+
|
445
|
+
cacert_file_config = %[
|
446
|
+
endpoint_url https://127.0.0.1:#{self.class.port}/api/
|
447
|
+
ssl_no_verify true
|
448
|
+
cacert_file /tmp/ssl.cert
|
449
|
+
]
|
450
|
+
d = create_driver cacert_file_config
|
451
|
+
FileUtils::touch '/tmp/ssl.cert'
|
452
|
+
http_opts = d.instance.http_opts(test_uri)
|
453
|
+
assert_equal true, http_opts[:use_ssl]
|
454
|
+
assert_equal OpenSSL::SSL::VERIFY_NONE, http_opts[:verify_mode]
|
455
|
+
assert_equal true, File.file?('/tmp/ssl.cert')
|
456
|
+
puts http_opts
|
457
|
+
assert_equal File.join('/tmp/ssl.cert'), http_opts[:ca_file]
|
425
458
|
end
|
426
459
|
|
427
460
|
def test_emit_form_ssl
|
@@ -438,4 +471,20 @@ class HTTPSOutputTest < HTTPOutputTestBase
|
|
438
471
|
|
439
472
|
assert_equal '50', record[:form]['field1']
|
440
473
|
end
|
474
|
+
|
475
|
+
def test_emit_form_ssl_ca
|
476
|
+
config = %[
|
477
|
+
endpoint_url https://127.0.0.1:#{self.class.port}/api/
|
478
|
+
ssl_no_verify true
|
479
|
+
cacert_file /tmp/ssl.cert
|
480
|
+
]
|
481
|
+
d = create_driver config
|
482
|
+
d.emit({ 'field1' => 50 })
|
483
|
+
d.run
|
484
|
+
|
485
|
+
assert_equal 1, @posts.size
|
486
|
+
record = @posts[0]
|
487
|
+
|
488
|
+
assert_equal '50', record[:form]['field1']
|
489
|
+
end
|
441
490
|
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: 0.3.
|
4
|
+
version: 0.3.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-
|
11
|
+
date: 2018-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yajl-ruby
|