fluent-plugin-out-http 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fluent-plugin-out-http.gemspec +1 -1
- data/lib/fluent/plugin/out_http.rb +6 -25
- data/test/plugin/test_out_http.rb +22 -1
- 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: dafd3484539763a106d90e6bb4acf4ca7877a3734a0a256bfa5b614e0de16a15
|
4
|
+
data.tar.gz: a1fc0b58b3d6adcb44c686715030710e2d96b188842eeb61e8f3eb0b9746b18a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f91c5e5737673625a691920e751e2e9e85e7b06aefbd2cddca85de54cdc19b01168ccbf746001b35a90cfeaa384cd7d5768f7e680bb4e0fa02c703131bb5374
|
7
|
+
data.tar.gz: 1943958c63b8e7feb8f2c43a78875bb672eb33e38677328c9d268014a250ef5bab9c1180edfec892d0e278d2fd8cef54055525f2f59b5d2212b335b0e167cfad
|
@@ -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.0.
|
5
|
+
gem.version = "1.0.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}
|
@@ -21,10 +21,10 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
|
|
21
21
|
config_param :ssl_no_verify, :bool, :default => false
|
22
22
|
|
23
23
|
# HTTP method
|
24
|
-
config_param :http_method, :
|
24
|
+
config_param :http_method, :enum, list: [:get, :put, :post, :delete], :default => :post
|
25
25
|
|
26
26
|
# form | json
|
27
|
-
config_param :serializer, :
|
27
|
+
config_param :serializer, :enum, list: [:json, :form], :default => :form
|
28
28
|
|
29
29
|
# Simple rate limiting: ignore any records within `rate_limit_msec`
|
30
30
|
# since the last one.
|
@@ -33,8 +33,8 @@ 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
|
-
#
|
37
|
-
config_param :authentication, :
|
36
|
+
# 'none' | 'basic'
|
37
|
+
config_param :authentication, :enum, list: [:none, :basic], :default => :none
|
38
38
|
config_param :username, :string, :default => ''
|
39
39
|
config_param :password, :string, :default => '', :secret => true
|
40
40
|
# Switch non-buffered/buffered plugin
|
@@ -55,26 +55,6 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
|
|
55
55
|
OpenSSL::SSL::VERIFY_PEER
|
56
56
|
end
|
57
57
|
|
58
|
-
serializers = [:json, :form]
|
59
|
-
@serializer = if serializers.include? @serializer.intern
|
60
|
-
@serializer.intern
|
61
|
-
else
|
62
|
-
:form
|
63
|
-
end
|
64
|
-
|
65
|
-
http_methods = [:get, :put, :post, :delete]
|
66
|
-
@http_method = if http_methods.include? @http_method.intern
|
67
|
-
@http_method.intern
|
68
|
-
else
|
69
|
-
:post
|
70
|
-
end
|
71
|
-
|
72
|
-
@auth = case @authentication
|
73
|
-
when 'basic' then :basic
|
74
|
-
else
|
75
|
-
:none
|
76
|
-
end
|
77
|
-
|
78
58
|
@last_request_time = nil
|
79
59
|
raise Fluent::ConfigError, "'tag' in chunk_keys is required." if !@chunk_key_tag && @buffered
|
80
60
|
end
|
@@ -136,7 +116,7 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
|
|
136
116
|
res = nil
|
137
117
|
|
138
118
|
begin
|
139
|
-
if @
|
119
|
+
if @authentication == :basic
|
140
120
|
req.basic_auth(@username, @password)
|
141
121
|
end
|
142
122
|
@last_request_time = Time.now.to_f
|
@@ -186,6 +166,7 @@ class Fluent::Plugin::HTTPOutput < Fluent::Plugin::Output
|
|
186
166
|
|
187
167
|
def write(chunk)
|
188
168
|
tag = chunk.metadata.tag
|
169
|
+
@endpoint_url = extract_placeholders(@endpoint_url, chunk.metadata)
|
189
170
|
chunk.msgpack_each do |time, record|
|
190
171
|
handle_record(tag, time, record)
|
191
172
|
end
|
@@ -42,7 +42,7 @@ class HTTPOutputTestBase < Test::Unit::TestCase
|
|
42
42
|
srv = WEBrick::HTTPServer.new(self.class.server_config)
|
43
43
|
begin
|
44
44
|
allowed_methods = %w(POST PUT)
|
45
|
-
srv.mount_proc('/api
|
45
|
+
srv.mount_proc('/api') { |req,res|
|
46
46
|
@requests += 1
|
47
47
|
unless allowed_methods.include? req.request_method
|
48
48
|
res.status = 405
|
@@ -70,6 +70,10 @@ class HTTPOutputTestBase < Test::Unit::TestCase
|
|
70
70
|
|
71
71
|
res.status = 200
|
72
72
|
}
|
73
|
+
srv.mount_proc('/modified-api') { |req,res|
|
74
|
+
res.status = 303
|
75
|
+
res.body = 'See other'
|
76
|
+
}
|
73
77
|
srv.mount_proc('/') { |req,res|
|
74
78
|
res.status = 200
|
75
79
|
res.body = 'running'
|
@@ -118,6 +122,8 @@ class HTTPOutputTestBase < Test::Unit::TestCase
|
|
118
122
|
assert_equal 'gauge', @posts[0][:form]['mode']
|
119
123
|
assert_nil @posts[0][:auth]
|
120
124
|
|
125
|
+
assert_equal '303', client.request_get('/modified-api').code
|
126
|
+
|
121
127
|
@auth = true
|
122
128
|
|
123
129
|
assert_equal '403', client.request_post('/api/service/metrics/pos', 'number=30&mode=gauge', post_header).code
|
@@ -256,6 +262,21 @@ class HTTPOutputTest < HTTPOutputTestBase
|
|
256
262
|
assert_equal 2, @posts.size
|
257
263
|
end
|
258
264
|
|
265
|
+
def test_emit_form_with_placeholders
|
266
|
+
d = create_driver(Fluent::Config::Element.new(
|
267
|
+
'ROOT', '' ,
|
268
|
+
{"endpoint_url" => "${endpoint}",
|
269
|
+
"buffered" => true},
|
270
|
+
[Fluent::Config::Element.new('buffer', 'tag, endpoint', {"@type" => "memory"} ,[])]))
|
271
|
+
|
272
|
+
d.run(default_tag: 'test.metrics', shutdown: false) do
|
273
|
+
d.feed({ 'field1' => 50, 'field2' => 20, 'field3' => 10, 'otherfield' => 1, 'binary' => "\xe3\x81\x82".force_encoding("ascii-8bit"), 'endpoint' => "http://127.0.0.1:#{self.class.port}/modified-api/" })
|
274
|
+
end
|
275
|
+
|
276
|
+
assert_equal 0, @posts.size # post into other URI
|
277
|
+
assert_equal "http://127.0.0.1:#{self.class.port}/modified-api/", d.instance.endpoint_url
|
278
|
+
end
|
279
|
+
|
259
280
|
def test_emit_form_put
|
260
281
|
d = create_driver CONFIG_PUT + %[buffered true]
|
261
282
|
d.run(default_tag: 'test.metrics', shutdown: false) do
|
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.0.
|
4
|
+
version: 1.0.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-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yajl-ruby
|