fluent-plugin-http 0.4.1 → 1.0.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 +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/fluent/plugin/out_http.rb +66 -24
- metadata +59 -40
- metadata.gz.sig +1 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6618d3e9884d9b348147b57d84d2c13554ae87b323e1aa784cb5c3bf062e3ae7
|
4
|
+
data.tar.gz: a58e2cdd0e07ac75f929a74263d96e0848a5f2cab12e090d3b7aa7c04b9e50da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 936fce15231ac524bc19bb872e4591137a0139d6b858d77f96499b7b2041942206e3d39f758d0d49f1723ad435bc42262390ad2a7a1ed3a3d04ce2b1a52c03cd
|
7
|
+
data.tar.gz: 7fcebcb3aadf1d406e51a05d303490ebae5758f6df70bc777200aade4b2cf01c9aeb68b6610519f864e1a27fdd21b042910194de7e600ef005c8c4132876c647
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
Binary file
|
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'fluent/output'
|
4
|
-
require 'uri'
|
5
4
|
require 'net/http'
|
6
|
-
require '
|
5
|
+
require 'oj'
|
6
|
+
require 'uri'
|
7
7
|
|
8
8
|
# Fluentd
|
9
9
|
module Fluent
|
10
10
|
# The out_http buffered output plugin sends event records via HTTP.
|
11
|
-
class HTTPOutput < ObjectBufferedOutput
|
11
|
+
class HTTPOutput < ObjectBufferedOutput # rubocop:disable Metrics/ClassLength
|
12
12
|
Fluent::Plugin.register_output('http', self)
|
13
13
|
|
14
14
|
desc 'URL to send event records to'
|
@@ -20,6 +20,15 @@ module Fluent
|
|
20
20
|
desc 'Authorization token'
|
21
21
|
config_param :authorization_token, :string, default: nil, secret: true
|
22
22
|
|
23
|
+
desc 'Keep-alive timeout'
|
24
|
+
config_param :keep_alive_timeout, :float, default: 60.0
|
25
|
+
|
26
|
+
desc 'Basic auth username'
|
27
|
+
config_param :username, :string, default: nil
|
28
|
+
|
29
|
+
desc 'Basic auth password'
|
30
|
+
config_param :password, :string, default: nil, secret: true
|
31
|
+
|
23
32
|
def initialize
|
24
33
|
require 'fluent/plugin/http/error'
|
25
34
|
|
@@ -36,16 +45,9 @@ module Fluent
|
|
36
45
|
@url = validate_url(url)
|
37
46
|
@accept_status_code = validate_accept_status_code(accept_status_code)
|
38
47
|
@authorization_token = validate_authorization_token(authorization_token)
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
#
|
43
|
-
# @return void
|
44
|
-
def start
|
45
|
-
super
|
46
|
-
|
47
|
-
is_https = url.scheme == 'https'
|
48
|
-
@http = Net::HTTP.start(url.host, url.port, use_ssl: is_https)
|
48
|
+
@keep_alive_timeout = validate_keep_alive_timeout(keep_alive_timeout)
|
49
|
+
@username = validate_username(username)
|
50
|
+
@password = validate_password(password)
|
49
51
|
end
|
50
52
|
|
51
53
|
# Hook method that is called at the shutdown
|
@@ -54,7 +56,7 @@ module Fluent
|
|
54
56
|
def shutdown
|
55
57
|
super
|
56
58
|
|
57
|
-
|
59
|
+
disconnect
|
58
60
|
end
|
59
61
|
|
60
62
|
# Serializes the event
|
@@ -73,6 +75,8 @@ module Fluent
|
|
73
75
|
# formatted events
|
74
76
|
# @return void
|
75
77
|
def write(chunk)
|
78
|
+
return if chunk.empty?
|
79
|
+
|
76
80
|
records = []
|
77
81
|
|
78
82
|
chunk.msgpack_each do |tag_time_record|
|
@@ -80,30 +84,43 @@ module Fluent
|
|
80
84
|
end
|
81
85
|
|
82
86
|
post_records = post_records_request(records)
|
83
|
-
response =
|
87
|
+
response = connect.request(post_records)
|
84
88
|
|
85
89
|
return if accept_status_code.include?(response.code)
|
90
|
+
|
86
91
|
raise ResponseError.error(post_records, response)
|
87
92
|
end
|
88
93
|
|
89
94
|
private
|
90
95
|
|
91
|
-
|
96
|
+
def connect
|
97
|
+
@http ||= Net::HTTP.start(
|
98
|
+
url.host,
|
99
|
+
url.port,
|
100
|
+
use_ssl: url.scheme == 'https',
|
101
|
+
keep_alive_timeout: keep_alive_timeout
|
102
|
+
)
|
103
|
+
end
|
92
104
|
|
93
|
-
|
94
|
-
|
105
|
+
def disconnect
|
106
|
+
return unless defined?(@http)
|
107
|
+
return unless @http
|
95
108
|
|
96
|
-
|
109
|
+
@http.finish
|
110
|
+
end
|
97
111
|
|
98
112
|
def post_records_request(records)
|
99
113
|
Net::HTTP::Post.new(url).tap do |request|
|
100
|
-
request.body =
|
101
|
-
|
102
|
-
request
|
114
|
+
request.body = Oj.dump(records)
|
115
|
+
|
116
|
+
request.content_type = 'application/json'
|
117
|
+
request['User-Agent'] = 'FluentPluginHTTP'
|
103
118
|
|
104
119
|
if authorization_token
|
105
120
|
request['Authorization'] = "Token token=#{authorization_token}"
|
106
121
|
end
|
122
|
+
|
123
|
+
request.basic_auth(username, password) if username
|
107
124
|
end
|
108
125
|
end
|
109
126
|
|
@@ -113,8 +130,8 @@ module Fluent
|
|
113
130
|
|
114
131
|
raise Fluent::ConfigError,
|
115
132
|
"Unacceptable URL scheme, expected HTTP or HTTPs: #{test_url}"
|
116
|
-
rescue URI::InvalidURIError =>
|
117
|
-
raise Fluent::ConfigError,
|
133
|
+
rescue URI::InvalidURIError => e
|
134
|
+
raise Fluent::ConfigError, e
|
118
135
|
end
|
119
136
|
|
120
137
|
def validate_accept_status_code(status_codes)
|
@@ -138,5 +155,30 @@ module Fluent
|
|
138
155
|
|
139
156
|
raise Fluent::ConfigError, "Invalid authorization token: #{value.inspect}"
|
140
157
|
end
|
158
|
+
|
159
|
+
def validate_keep_alive_timeout(value)
|
160
|
+
return value if value >= 0
|
161
|
+
|
162
|
+
raise Fluent::ConfigError, "Invalid keep-alive timeout: #{value.inspect}"
|
163
|
+
end
|
164
|
+
|
165
|
+
def validate_username(value)
|
166
|
+
return value if value.nil?
|
167
|
+
|
168
|
+
if authorization_token
|
169
|
+
raise Fluent::ConfigError,
|
170
|
+
'Mutually exclusive: authorization_token and username'
|
171
|
+
end
|
172
|
+
|
173
|
+
return value unless value.empty?
|
174
|
+
|
175
|
+
raise Fluent::ConfigError, "Invalid username: #{value.inspect}"
|
176
|
+
end
|
177
|
+
|
178
|
+
def validate_password(value)
|
179
|
+
return value if value.nil? || username
|
180
|
+
|
181
|
+
raise Fluent::ConfigError, 'Password requires a username'
|
182
|
+
end
|
141
183
|
end
|
142
184
|
end
|
metadata
CHANGED
@@ -1,143 +1,162 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
|
-
cert_chain:
|
11
|
-
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDGjCCAgKgAwIBAgIBATANBgkqhkiG9w0BAQsFADAaMRgwFgYDVQQDDA9lZmly
|
14
|
+
L0RDPXNveWxlbnQwHhcNMjAwMzA3MDEzNzUwWhcNMjEwMzA3MDEzNzUwWjAaMRgw
|
15
|
+
FgYDVQQDDA9lZmlyL0RDPXNveWxlbnQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
|
16
|
+
ggEKAoIBAQC2DMbzgA39U+3VTMjXn+0jnOQyLdmXQ5EXgSLKCgBLIcFTc9J47Th0
|
17
|
+
7Yb/f4RzWh49/EkDBiDtLqFeKBYsj3q0e8tRCAs32NtVyl/4FDyJvWsK3R2tcXOV
|
18
|
+
qxs48J3CgG+rFLOcMC9YF4FPTkz4p3EYGFVjZTbiqyVVuIZzWtrwdZesBVgpBRyN
|
19
|
+
8sEyNoi8vcDiOmEwf9/TVMTDf/wu6a+i3LNVGYWlvgMJRssaAnj/IbFFtPTz30Hx
|
20
|
+
eTUdfJu8YbwRspfFzcJGLf32E7vXfmHHqNzqjh4zD9sVpvTHbqLLsgVa+nYHPHAe
|
21
|
+
dzSZ5gZjG1oZ7hZDCJoEPj0oCHT0qkuXAgMBAAGjazBpMAkGA1UdEwQCMAAwCwYD
|
22
|
+
VR0PBAQDAgSwMB0GA1UdDgQWBBSsvp1HAfA+QTjOg/ehyhv7adp0FjAXBgNVHREE
|
23
|
+
EDAOgQxlZmlyQHNveWxlbnQwFwYDVR0SBBAwDoEMZWZpckBzb3lsZW50MA0GCSqG
|
24
|
+
SIb3DQEBCwUAA4IBAQBsJ7htnm3RB5xQwzC2agRAgG2ax5uaD6lCEPWshGJbfT6v
|
25
|
+
jaRrwrPSbaxBTD2v8QpXJe/fALJKWHUbNZilZU2t7HyQkfSyVQyLYcjo7lWFoHA1
|
26
|
+
z0YB3dCGcMkvLa7r73ynEtYbnYfesbXVlcRJG7SgJqWvZMnj1HnYfBevlcjSBFy2
|
27
|
+
5xZKSwreHM+va8McxpEZmG3ecdefRQ1u+xZabamN2hhel3nKF1BUBqgxYWXYRkZP
|
28
|
+
VIAqJBK/gwFlRxVYjmi2w4Ouc4wL8HtX104yQqOuD9gVPN6PJecue66As7i2I/2q
|
29
|
+
EARmnubhy24GUdxEooHV6pOs1mLLRuFepMgBnHfs
|
30
|
+
-----END CERTIFICATE-----
|
31
|
+
date: 2021-01-01 00:00:00.000000000 Z
|
12
32
|
dependencies:
|
13
33
|
- !ruby/object:Gem::Dependency
|
14
34
|
name: fluentd
|
15
35
|
requirement: !ruby/object:Gem::Requirement
|
16
36
|
requirements:
|
17
|
-
- - "
|
37
|
+
- - ">="
|
18
38
|
- !ruby/object:Gem::Version
|
19
39
|
version: '0.12'
|
20
40
|
type: :runtime
|
21
41
|
prerelease: false
|
22
42
|
version_requirements: !ruby/object:Gem::Requirement
|
23
43
|
requirements:
|
24
|
-
- - "
|
44
|
+
- - ">="
|
25
45
|
- !ruby/object:Gem::Version
|
26
46
|
version: '0.12'
|
27
47
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
48
|
+
name: oj
|
29
49
|
requirement: !ruby/object:Gem::Requirement
|
30
50
|
requirements:
|
31
51
|
- - "~>"
|
32
52
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
34
|
-
type: :
|
53
|
+
version: '3.3'
|
54
|
+
type: :runtime
|
35
55
|
prerelease: false
|
36
56
|
version_requirements: !ruby/object:Gem::Requirement
|
37
57
|
requirements:
|
38
58
|
- - "~>"
|
39
59
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
60
|
+
version: '3.3'
|
41
61
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
62
|
+
name: pry
|
43
63
|
requirement: !ruby/object:Gem::Requirement
|
44
64
|
requirements:
|
45
|
-
- - "
|
65
|
+
- - ">="
|
46
66
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
67
|
+
version: '0'
|
48
68
|
type: :development
|
49
69
|
prerelease: false
|
50
70
|
version_requirements: !ruby/object:Gem::Requirement
|
51
71
|
requirements:
|
52
|
-
- - "
|
72
|
+
- - ">="
|
53
73
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
74
|
+
version: '0'
|
55
75
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
76
|
+
name: rake
|
57
77
|
requirement: !ruby/object:Gem::Requirement
|
58
78
|
requirements:
|
59
|
-
- - "
|
79
|
+
- - ">="
|
60
80
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0
|
81
|
+
version: '0'
|
62
82
|
type: :development
|
63
83
|
prerelease: false
|
64
84
|
version_requirements: !ruby/object:Gem::Requirement
|
65
85
|
requirements:
|
66
|
-
- - "
|
86
|
+
- - ">="
|
67
87
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0
|
88
|
+
version: '0'
|
69
89
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
90
|
+
name: rubocop
|
71
91
|
requirement: !ruby/object:Gem::Requirement
|
72
92
|
requirements:
|
73
|
-
- - "
|
93
|
+
- - ">="
|
74
94
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
95
|
+
version: '0'
|
76
96
|
type: :development
|
77
97
|
prerelease: false
|
78
98
|
version_requirements: !ruby/object:Gem::Requirement
|
79
99
|
requirements:
|
80
|
-
- - "
|
100
|
+
- - ">="
|
81
101
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
102
|
+
version: '0'
|
83
103
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
104
|
+
name: test-unit
|
85
105
|
requirement: !ruby/object:Gem::Requirement
|
86
106
|
requirements:
|
87
107
|
- - "~>"
|
88
108
|
- !ruby/object:Gem::Version
|
89
|
-
version: '2
|
109
|
+
version: '3.2'
|
90
110
|
type: :development
|
91
111
|
prerelease: false
|
92
112
|
version_requirements: !ruby/object:Gem::Requirement
|
93
113
|
requirements:
|
94
114
|
- - "~>"
|
95
115
|
- !ruby/object:Gem::Version
|
96
|
-
version: '2
|
116
|
+
version: '3.2'
|
97
117
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
118
|
+
name: webmock
|
99
119
|
requirement: !ruby/object:Gem::Requirement
|
100
120
|
requirements:
|
101
121
|
- - "~>"
|
102
122
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
123
|
+
version: '2.1'
|
104
124
|
type: :development
|
105
125
|
prerelease: false
|
106
126
|
version_requirements: !ruby/object:Gem::Requirement
|
107
127
|
requirements:
|
108
128
|
- - "~>"
|
109
129
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
111
|
-
description:
|
112
|
-
email:
|
130
|
+
version: '2.1'
|
131
|
+
description:
|
132
|
+
email:
|
113
133
|
executables: []
|
114
134
|
extensions: []
|
115
135
|
extra_rdoc_files: []
|
116
136
|
files:
|
117
137
|
- lib/fluent/plugin/http/error.rb
|
118
138
|
- lib/fluent/plugin/out_http.rb
|
119
|
-
homepage:
|
139
|
+
homepage: https://github.com/soylent/fluent-plugin-http
|
120
140
|
licenses:
|
121
141
|
- Apache-2.0
|
122
142
|
metadata: {}
|
123
|
-
post_install_message:
|
143
|
+
post_install_message:
|
124
144
|
rdoc_options: []
|
125
145
|
require_paths:
|
126
146
|
- lib
|
127
147
|
required_ruby_version: !ruby/object:Gem::Requirement
|
128
148
|
requirements:
|
129
|
-
- - "
|
149
|
+
- - "~>"
|
130
150
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
151
|
+
version: '2.1'
|
132
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
153
|
requirements:
|
134
154
|
- - ">="
|
135
155
|
- !ruby/object:Gem::Version
|
136
156
|
version: '0'
|
137
157
|
requirements: []
|
138
|
-
|
139
|
-
|
140
|
-
signing_key:
|
158
|
+
rubygems_version: 3.1.4
|
159
|
+
signing_key:
|
141
160
|
specification_version: 4
|
142
161
|
summary: Fluentd output plugin that sends event records via HTTP
|
143
162
|
test_files: []
|
metadata.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
'?tXs�����y�=�oUMI���]r`�B�*%'.����<���Բ��D��Η̃l^
|