fluent-plugin-http 0.4.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +2 -0
- data.tar.gz.sig +3 -0
- data/lib/fluent/plugin/out_http.rb +62 -21
- metadata +52 -45
- 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: 728702ac71e92c7912c589f5ea21c32ec6b4e824477051f158cfd0828b300a25
|
4
|
+
data.tar.gz: 24f01adfe8074a1d76e693df7f39e6b359ab93e241b9abd18959f373dd61ca4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8435f519f8f21745ff6a6dcd690166af709ebd2513dd5318fc97342f9f9f9d241fb61774b3192a567111d1c3b91aa848ea25a5e5a37397647cb2334493de6d37
|
7
|
+
data.tar.gz: 340993979eaab93b449a57b995b0584f9e14fd652cc9a397f7a8e89ce49af048630761f10e2344c1a15fcc7653cc7cf69f78d0c4d3327c0bdeff0d136f0c4a45
|
checksums.yaml.gz.sig
ADDED
data.tar.gz.sig
ADDED
@@ -8,7 +8,7 @@ require 'uri'
|
|
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,31 +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
114
|
request.body = Oj.dump(records)
|
101
115
|
|
102
|
-
request.content_type =
|
103
|
-
request['User-Agent'] =
|
116
|
+
request.content_type = 'application/json'
|
117
|
+
request['User-Agent'] = 'FluentPluginHTTP'
|
104
118
|
|
105
119
|
if authorization_token
|
106
120
|
request['Authorization'] = "Token token=#{authorization_token}"
|
107
121
|
end
|
122
|
+
|
123
|
+
request.basic_auth(username, password) if username
|
108
124
|
end
|
109
125
|
end
|
110
126
|
|
@@ -114,8 +130,8 @@ module Fluent
|
|
114
130
|
|
115
131
|
raise Fluent::ConfigError,
|
116
132
|
"Unacceptable URL scheme, expected HTTP or HTTPs: #{test_url}"
|
117
|
-
rescue URI::InvalidURIError =>
|
118
|
-
raise Fluent::ConfigError,
|
133
|
+
rescue URI::InvalidURIError => e
|
134
|
+
raise Fluent::ConfigError, e
|
119
135
|
end
|
120
136
|
|
121
137
|
def validate_accept_status_code(status_codes)
|
@@ -139,5 +155,30 @@ module Fluent
|
|
139
155
|
|
140
156
|
raise Fluent::ConfigError, "Invalid authorization token: #{value.inspect}"
|
141
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
|
142
183
|
end
|
143
184
|
end
|
metadata
CHANGED
@@ -1,85 +1,104 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
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
|
+
MIIC6DCCAdCgAwIBAgIBAjANBgkqhkiG9w0BAQsFADAaMRgwFgYDVQQDDA9lZmly
|
14
|
+
L0RDPXNveWxlbnQwHhcNMjEwNTE4MDExNjEzWhcNMjIwNTE4MDExNjEzWjAaMRgw
|
15
|
+
FgYDVQQDDA9lZmlyL0RDPXNveWxlbnQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
|
16
|
+
ggEKAoIBAQC2DMbzgA39U+3VTMjXn+0jnOQyLdmXQ5EXgSLKCgBLIcFTc9J47Th0
|
17
|
+
7Yb/f4RzWh49/EkDBiDtLqFeKBYsj3q0e8tRCAs32NtVyl/4FDyJvWsK3R2tcXOV
|
18
|
+
qxs48J3CgG+rFLOcMC9YF4FPTkz4p3EYGFVjZTbiqyVVuIZzWtrwdZesBVgpBRyN
|
19
|
+
8sEyNoi8vcDiOmEwf9/TVMTDf/wu6a+i3LNVGYWlvgMJRssaAnj/IbFFtPTz30Hx
|
20
|
+
eTUdfJu8YbwRspfFzcJGLf32E7vXfmHHqNzqjh4zD9sVpvTHbqLLsgVa+nYHPHAe
|
21
|
+
dzSZ5gZjG1oZ7hZDCJoEPj0oCHT0qkuXAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYD
|
22
|
+
VR0PBAQDAgSwMB0GA1UdDgQWBBSsvp1HAfA+QTjOg/ehyhv7adp0FjANBgkqhkiG
|
23
|
+
9w0BAQsFAAOCAQEAjdz9WfpI7CU4stw8NK9ODdOKaKiCi+TSQWjolHf6DA0i/KsK
|
24
|
+
km3z/fDViF+kfG6YOdtxTPEyua0hzeIPUVYrA/u8gnzc0Q/qaW5OS86T7Kfou7Gq
|
25
|
+
BtuQbYgD/X+k62pFijR8VmK/5MCkzGzkNIzhiWnoNsGBIlbviSYYrSOY8HX/3AII
|
26
|
+
byLjhl7M3heb8m5jF+4jgXJfAOs6gtAYibX3YKrplewpJ3zd+7ebIXcHnob4UODK
|
27
|
+
WuleLMzqh7WrqMwrLkhSEnyo36OS8fZBNr8WPYAFpsz0z5TbR/8ymGAXobU87DdV
|
28
|
+
J4zDM21+9T3I6Jzw8TrlaRx7kUytTRxVgjqPlA==
|
29
|
+
-----END CERTIFICATE-----
|
30
|
+
date: 2021-05-18 00:00:00.000000000 Z
|
12
31
|
dependencies:
|
13
32
|
- !ruby/object:Gem::Dependency
|
14
33
|
name: fluentd
|
15
34
|
requirement: !ruby/object:Gem::Requirement
|
16
35
|
requirements:
|
17
|
-
- - "
|
36
|
+
- - ">="
|
18
37
|
- !ruby/object:Gem::Version
|
19
38
|
version: '0.12'
|
20
39
|
type: :runtime
|
21
40
|
prerelease: false
|
22
41
|
version_requirements: !ruby/object:Gem::Requirement
|
23
42
|
requirements:
|
24
|
-
- - "
|
43
|
+
- - ">="
|
25
44
|
- !ruby/object:Gem::Version
|
26
45
|
version: '0.12'
|
27
46
|
- !ruby/object:Gem::Dependency
|
28
47
|
name: oj
|
29
48
|
requirement: !ruby/object:Gem::Requirement
|
30
49
|
requirements:
|
31
|
-
- - "
|
50
|
+
- - "~>"
|
32
51
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
52
|
+
version: '3.3'
|
34
53
|
type: :runtime
|
35
54
|
prerelease: false
|
36
55
|
version_requirements: !ruby/object:Gem::Requirement
|
37
56
|
requirements:
|
38
|
-
- - "
|
57
|
+
- - "~>"
|
39
58
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
59
|
+
version: '3.3'
|
41
60
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
61
|
+
name: pry
|
43
62
|
requirement: !ruby/object:Gem::Requirement
|
44
63
|
requirements:
|
45
|
-
- - "
|
64
|
+
- - ">="
|
46
65
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
66
|
+
version: '0'
|
48
67
|
type: :development
|
49
68
|
prerelease: false
|
50
69
|
version_requirements: !ruby/object:Gem::Requirement
|
51
70
|
requirements:
|
52
|
-
- - "
|
71
|
+
- - ">="
|
53
72
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
73
|
+
version: '0'
|
55
74
|
- !ruby/object:Gem::Dependency
|
56
75
|
name: rake
|
57
76
|
requirement: !ruby/object:Gem::Requirement
|
58
77
|
requirements:
|
59
|
-
- - "
|
78
|
+
- - ">="
|
60
79
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
80
|
+
version: '0'
|
62
81
|
type: :development
|
63
82
|
prerelease: false
|
64
83
|
version_requirements: !ruby/object:Gem::Requirement
|
65
84
|
requirements:
|
66
|
-
- - "
|
85
|
+
- - ">="
|
67
86
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
87
|
+
version: '0'
|
69
88
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
89
|
+
name: rubocop
|
71
90
|
requirement: !ruby/object:Gem::Requirement
|
72
91
|
requirements:
|
73
92
|
- - "~>"
|
74
93
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
94
|
+
version: 0.57.0
|
76
95
|
type: :development
|
77
96
|
prerelease: false
|
78
97
|
version_requirements: !ruby/object:Gem::Requirement
|
79
98
|
requirements:
|
80
99
|
- - "~>"
|
81
100
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
101
|
+
version: 0.57.0
|
83
102
|
- !ruby/object:Gem::Dependency
|
84
103
|
name: test-unit
|
85
104
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,33 +127,19 @@ dependencies:
|
|
108
127
|
- - "~>"
|
109
128
|
- !ruby/object:Gem::Version
|
110
129
|
version: '2.1'
|
111
|
-
|
112
|
-
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0.45'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0.45'
|
125
|
-
description:
|
126
|
-
email:
|
130
|
+
description:
|
131
|
+
email:
|
127
132
|
executables: []
|
128
133
|
extensions: []
|
129
134
|
extra_rdoc_files: []
|
130
135
|
files:
|
131
136
|
- lib/fluent/plugin/http/error.rb
|
132
137
|
- lib/fluent/plugin/out_http.rb
|
133
|
-
homepage:
|
138
|
+
homepage: https://github.com/soylent/fluent-plugin-http
|
134
139
|
licenses:
|
135
140
|
- Apache-2.0
|
136
141
|
metadata: {}
|
137
|
-
post_install_message:
|
142
|
+
post_install_message:
|
138
143
|
rdoc_options: []
|
139
144
|
require_paths:
|
140
145
|
- lib
|
@@ -142,16 +147,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
142
147
|
requirements:
|
143
148
|
- - ">="
|
144
149
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
150
|
+
version: '2.1'
|
151
|
+
- - "<"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '4'
|
146
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
155
|
requirements:
|
148
156
|
- - ">="
|
149
157
|
- !ruby/object:Gem::Version
|
150
158
|
version: '0'
|
151
159
|
requirements: []
|
152
|
-
|
153
|
-
|
154
|
-
signing_key:
|
160
|
+
rubygems_version: 3.2.3
|
161
|
+
signing_key:
|
155
162
|
specification_version: 4
|
156
|
-
summary: Fluentd output plugin
|
163
|
+
summary: Fluentd output plugin to send logs to an HTTP endpoint
|
157
164
|
test_files: []
|
metadata.gz.sig
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
^S��g<!b,�M��CE\���e����z��>�p"&x��)ŋ%���d��IZ�*��6�� {3�_�������?^�@�;���Y莲`ü��Ov�H��i��F���(���
|