logstash-input-http 3.0.8 → 3.0.9
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/LICENSE +1 -1
- data/lib/logstash/inputs/http.rb +24 -16
- data/logstash-input-http.gemspec +2 -1
- data/spec/inputs/http_spec.rb +15 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42ceeaf8d8b30792be582944f25f31f2a49fe9fb63907aaaf01d46ee6b94b684
|
4
|
+
data.tar.gz: d989b314584736c51690656468c4ef0bbcba755cf803b5df3bf337b3650702a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67b672d9f6dd5d7d0a9eb877cd7d7a0203c70f2e8abcbd57f6c51d977edfe454d06f47cce6189196f3a6b9d45cf90dd4725a3cd4396a7d071ddcb77b00cb0f1d
|
7
|
+
data.tar.gz: fa6975d644e0089746c9fe5507138c665969ffa4a8c45d7e5dd01f860b9e55a1274505bcb9dd00ac5b363ada9051fc01a6ecf37e417a3efbed936b4136dbb01a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 3.0.9
|
2
|
+
- Make sure default codec is also cloned for thread safety. https://github.com/logstash-plugins/logstash-input-http/pull/80
|
3
|
+
- Always flush codec after each request and codec decoding. https://github.com/logstash-plugins/logstash-input-http/pull/81
|
4
|
+
|
1
5
|
## 3.0.8
|
2
6
|
- In the event that all webserver threads are busy this plugin will now return a 429, busy, error.
|
3
7
|
|
data/LICENSE
CHANGED
data/lib/logstash/inputs/http.rb
CHANGED
@@ -92,7 +92,6 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
|
|
92
92
|
# mostly due to rack compliance
|
93
93
|
REJECTED_HEADERS = ["puma.socket", "rack.hijack?", "rack.hijack", "rack.url_scheme", "rack.after_reply", "rack.version", "rack.errors", "rack.multithread", "rack.multiprocess", "rack.run_once", "SCRIPT_NAME", "QUERY_STRING", "SERVER_PROTOCOL", "SERVER_SOFTWARE", "GATEWAY_INTERFACE"]
|
94
94
|
|
95
|
-
public
|
96
95
|
def register
|
97
96
|
require "logstash/util/http_compressed_requests"
|
98
97
|
@server = ::HTTPInputWebServer.new(nil) # we'll set the rack handler later
|
@@ -122,7 +121,9 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
|
|
122
121
|
@server.min_threads = 0
|
123
122
|
# The actual number of threads is one higher to let us reject additional requests
|
124
123
|
@server.max_threads = @threads + 1
|
125
|
-
|
124
|
+
|
125
|
+
# set the default codec in the @codecs hash so that it is also cloned in the write_slots
|
126
|
+
@codecs = { :default => @codec }
|
126
127
|
|
127
128
|
@additional_codecs.each do |content_type, codec|
|
128
129
|
@codecs[content_type] = LogStash::Plugin.lookup("codec", codec).new
|
@@ -151,13 +152,13 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
|
|
151
152
|
next [429, {}, BUSY_RESPONSE]
|
152
153
|
end
|
153
154
|
begin
|
154
|
-
codec = local_codecs
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
155
|
+
codec = local_codecs[req["content_type"]] || local_codecs[:default]
|
156
|
+
|
157
|
+
codec.decode(body.read) { |event| push_decorated_event(queue, event, remote_host, req) }
|
158
|
+
|
159
|
+
# since payloads are self-contained and we don't handle multipart we should flush
|
160
|
+
# the codec after each request.
|
161
|
+
codec.flush { |event| push_decorated_event(queue, event, remote_host, req) }
|
161
162
|
ensure
|
162
163
|
@write_slots.put(local_codecs)
|
163
164
|
end
|
@@ -186,7 +187,16 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
|
|
186
187
|
@server.run.join
|
187
188
|
end
|
188
189
|
|
190
|
+
def stop
|
191
|
+
return unless @server
|
192
|
+
@server.stop(true)
|
193
|
+
@server.binder.close if @server.binder
|
194
|
+
rescue IOError
|
195
|
+
# do nothing
|
196
|
+
end
|
197
|
+
|
189
198
|
private
|
199
|
+
|
190
200
|
def lowercase_keys(hash)
|
191
201
|
new_hash = {}
|
192
202
|
hash.each_pair do |k,v|
|
@@ -195,13 +205,11 @@ class LogStash::Inputs::Http < LogStash::Inputs::Base
|
|
195
205
|
new_hash
|
196
206
|
end
|
197
207
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
rescue IOError
|
204
|
-
# do nothing
|
208
|
+
def push_decorated_event(queue, event, host, headers)
|
209
|
+
event.set("host", host)
|
210
|
+
event.set("headers", headers)
|
211
|
+
decorate(event)
|
212
|
+
queue << event
|
205
213
|
end
|
206
214
|
|
207
215
|
end # class LogStash::Inputs::Http
|
data/logstash-input-http.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-input-http'
|
3
|
-
s.version = '3.0.
|
3
|
+
s.version = '3.0.9'
|
4
4
|
s.licenses = ['Apache License (2.0)']
|
5
5
|
s.summary = "Receives events over HTTP or HTTPS"
|
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"
|
@@ -26,5 +26,6 @@ Gem::Specification.new do |s|
|
|
26
26
|
|
27
27
|
s.add_development_dependency 'logstash-devutils'
|
28
28
|
s.add_development_dependency 'logstash-codec-json'
|
29
|
+
s.add_development_dependency 'logstash-codec-line'
|
29
30
|
s.add_development_dependency 'ftw'
|
30
31
|
end
|
data/spec/inputs/http_spec.rb
CHANGED
@@ -136,6 +136,7 @@ describe LogStash::Inputs::Http do
|
|
136
136
|
end
|
137
137
|
end
|
138
138
|
end
|
139
|
+
|
139
140
|
context "with json codec" do
|
140
141
|
subject { LogStash::Inputs::Http.new("port" => port, "codec" => "json") }
|
141
142
|
it "should parse the json body" do
|
@@ -145,6 +146,20 @@ describe LogStash::Inputs::Http do
|
|
145
146
|
end
|
146
147
|
end
|
147
148
|
|
149
|
+
context "with json_lines codec without final delimiter" do
|
150
|
+
subject { LogStash::Inputs::Http.new("port" => port, "codec" => "line") }
|
151
|
+
let(:line1) { "foo" }
|
152
|
+
let(:line2) { "bar" }
|
153
|
+
it "should parse all json_lines in body including last one" do
|
154
|
+
agent.post!("http://localhost:#{port}/meh.json", :body => "#{line1}\n#{line2}")
|
155
|
+
expect(queue.size).to eq(2)
|
156
|
+
event = queue.pop
|
157
|
+
expect(event.get("message")).to eq("foo")
|
158
|
+
event = queue.pop
|
159
|
+
expect(event.get("message")).to eq("bar")
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
148
163
|
context "when using a custom codec mapping" do
|
149
164
|
subject { LogStash::Inputs::Http.new("port" => port,
|
150
165
|
"additional_codecs" => { "application/json" => "plain" }) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,6 +120,20 @@ dependencies:
|
|
120
120
|
- - ">="
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: '0'
|
123
|
+
- !ruby/object:Gem::Dependency
|
124
|
+
requirement: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0'
|
129
|
+
name: logstash-codec-line
|
130
|
+
prerelease: false
|
131
|
+
type: :development
|
132
|
+
version_requirements: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
123
137
|
- !ruby/object:Gem::Dependency
|
124
138
|
requirement: !ruby/object:Gem::Requirement
|
125
139
|
requirements:
|