logstash-output-http 5.2.1 → 5.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/logstash/outputs/http.rb +17 -34
- data/logstash-output-http.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd00218e30610f309f7870230ffeff01b5d1481b38d8723cb2e938f2067a561b
|
4
|
+
data.tar.gz: 6c31789a86e548649b8ae995cab4e5927fe071d4491570d98c3ef454c28649fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ed20344862d2b1587d8a3b5cb8bb6b71de3c51ac75a91c85f5f1326185438f899ff08573de4613394c0fbae252c572e8c4996f05497e9cf081fc92c227182c1
|
7
|
+
data.tar.gz: 11248626b51ec811d865f761e01a7adf219b9967211c20abd71c901ff16d0e551201c7d931d209f19cf40fa6d7dad164e4dbe06f2c13ee2bfa7549bb8a16b1b3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 5.2.2
|
2
|
+
- Fix high CPU usage on retries in json_batch mode. [#89](https://github.com/logstash-plugins/logstash-output-http/pull/89)
|
3
|
+
- Enable compression in json_batch mode. [#89](https://github.com/logstash-plugins/logstash-output-http/pull/89)
|
4
|
+
|
1
5
|
## 5.2.1
|
2
6
|
- Docs: Set the default_codec doc attribute.
|
3
7
|
|
@@ -11,6 +11,8 @@ class LogStash::Outputs::Http < LogStash::Outputs::Base
|
|
11
11
|
|
12
12
|
concurrency :shared
|
13
13
|
|
14
|
+
attr_accessor :is_batch
|
15
|
+
|
14
16
|
VALID_METHODS = ["put", "post", "patch", "delete", "get", "head"]
|
15
17
|
|
16
18
|
RETRYABLE_MANTICORE_EXCEPTIONS = [
|
@@ -107,6 +109,7 @@ class LogStash::Outputs::Http < LogStash::Outputs::Base
|
|
107
109
|
end
|
108
110
|
end
|
109
111
|
|
112
|
+
@is_batch = @format == "json_batch"
|
110
113
|
|
111
114
|
@headers["Content-Type"] = @content_type
|
112
115
|
|
@@ -118,11 +121,7 @@ class LogStash::Outputs::Http < LogStash::Outputs::Base
|
|
118
121
|
|
119
122
|
def multi_receive(events)
|
120
123
|
return if events.empty?
|
121
|
-
|
122
|
-
send_json_batch(events)
|
123
|
-
else
|
124
|
-
send_events(events)
|
125
|
-
end
|
124
|
+
send_events(events)
|
126
125
|
end
|
127
126
|
|
128
127
|
class RetryTimerTask < java.util.TimerTask
|
@@ -138,29 +137,6 @@ class LogStash::Outputs::Http < LogStash::Outputs::Base
|
|
138
137
|
end
|
139
138
|
end
|
140
139
|
|
141
|
-
def send_json_batch(events)
|
142
|
-
attempt = 1
|
143
|
-
body = LogStash::Json.dump(events.map {|e| map_event(e) })
|
144
|
-
begin
|
145
|
-
while true
|
146
|
-
request = client.send(@http_method, @url, :body => body, :headers => @headers)
|
147
|
-
response = request.call
|
148
|
-
break if response_success?(response)
|
149
|
-
if retryable_response?(response)
|
150
|
-
log_retryable_response(response)
|
151
|
-
sleep_for_attempt attempt
|
152
|
-
attempt += 1
|
153
|
-
else
|
154
|
-
log_error_response(response, url, events)
|
155
|
-
end
|
156
|
-
end
|
157
|
-
rescue *RETRYABLE_MANTICORE_EXCEPTIONS => e
|
158
|
-
logger.warn("Encountered exception during http output send, will retry after delay", :message => e.message, :class => e.class.name)
|
159
|
-
sleep_for_attempt attempt
|
160
|
-
retry
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
140
|
def log_retryable_response(response)
|
165
141
|
if (response.code == 429)
|
166
142
|
@logger.debug? && @logger.debug("Encountered a 429 response, will retry. This is not serious, just flow control via HTTP")
|
@@ -182,15 +158,20 @@ class LogStash::Outputs::Http < LogStash::Outputs::Base
|
|
182
158
|
successes = java.util.concurrent.atomic.AtomicInteger.new(0)
|
183
159
|
failures = java.util.concurrent.atomic.AtomicInteger.new(0)
|
184
160
|
retries = java.util.concurrent.atomic.AtomicInteger.new(0)
|
185
|
-
|
161
|
+
event_count = @is_batch ? 1 : events.size
|
162
|
+
|
186
163
|
pending = Queue.new
|
187
|
-
|
164
|
+
if @is_batch
|
165
|
+
pending << [events, 0]
|
166
|
+
else
|
167
|
+
events.each {|e| pending << [e, 0]}
|
168
|
+
end
|
188
169
|
|
189
170
|
while popped = pending.pop
|
190
171
|
break if popped == :done
|
191
172
|
|
192
173
|
event, attempt = popped
|
193
|
-
|
174
|
+
|
194
175
|
send_event(event, attempt) do |action,event,attempt|
|
195
176
|
begin
|
196
177
|
action = :failure if action == :retry && !@retry_failed
|
@@ -213,7 +194,7 @@ class LogStash::Outputs::Http < LogStash::Outputs::Base
|
|
213
194
|
end
|
214
195
|
|
215
196
|
if action == :success || action == :failure
|
216
|
-
if successes.get+failures.get ==
|
197
|
+
if successes.get+failures.get == event_count
|
217
198
|
pending << :done
|
218
199
|
end
|
219
200
|
end
|
@@ -246,8 +227,8 @@ class LogStash::Outputs::Http < LogStash::Outputs::Base
|
|
246
227
|
body = event_body(event)
|
247
228
|
|
248
229
|
# Send the request
|
249
|
-
url = event.sprintf(@url)
|
250
|
-
headers = event_headers(event)
|
230
|
+
url = @is_batch ? @url : event.sprintf(@url)
|
231
|
+
headers = @is_batch ? @headers : event_headers(event)
|
251
232
|
|
252
233
|
# Compress the body and add appropriate header
|
253
234
|
if @http_compression == true
|
@@ -347,6 +328,8 @@ class LogStash::Outputs::Http < LogStash::Outputs::Base
|
|
347
328
|
LogStash::Json.dump(map_event(event))
|
348
329
|
elsif @format == "message"
|
349
330
|
event.sprintf(@message)
|
331
|
+
elsif @format == "json_batch"
|
332
|
+
LogStash::Json.dump(event.map {|e| map_event(e) })
|
350
333
|
else
|
351
334
|
encode(map_event(event))
|
352
335
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-output-http'
|
3
|
-
s.version = '5.2.
|
3
|
+
s.version = '5.2.2'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = "Sends events to a generic HTTP or HTTPS endpoint"
|
6
6
|
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.2.
|
4
|
+
version: 5.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
133
|
version: '0'
|
134
134
|
requirements: []
|
135
135
|
rubyforge_project:
|
136
|
-
rubygems_version: 2.6.
|
136
|
+
rubygems_version: 2.6.13
|
137
137
|
signing_key:
|
138
138
|
specification_version: 4
|
139
139
|
summary: Sends events to a generic HTTP or HTTPS endpoint
|