logstash-output-http 4.4.0 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c86f426c1122a3a0883cbe6da6b103147dfd642f
4
- data.tar.gz: 9e4a45eb530aeb912330e5f0a2158c9e7e00150c
3
+ metadata.gz: ab516b2caaebac6c6d423968cfa798482bc30397
4
+ data.tar.gz: b7d9d5435af8105187cfb60e17dd4290d588bed1
5
5
  SHA512:
6
- metadata.gz: 2a70f44491c198f1f7573c7619008c55217c1cc5b8fd8b6e46ee5873d4f4ee380c25a39a5dd4f48f5694b61b68f6cbcf63f480e5addf6cb5cf2c2feee7e7f85c
7
- data.tar.gz: f92ca3b533be5831a41b9586a091f3a27aac2fcb2a6ef7678bc4986318bc3e79874d47d2c91292fe4d6efc4bdbecd9de3cadeaca040acde50ca6acbdcc4aa79a
6
+ metadata.gz: 8ed52d96ab31cd98af7e053325ccc1bb4c209e281b10045ca504013c27a0924f53243ec5a88bdc72e5c57a892153a0006abc9a07f38e3a77eb02cc16352e8af8
7
+ data.tar.gz: 225f67b2638399123dd8ea26702f56cc1fd8c5aff8482eff33d6e28d3d81b1c7b27998ce26f5ad0821756743120c0e4cc36218c7de11e01467a2143cd016f0ba
@@ -1,8 +1,5 @@
1
- ## 4.4.0
2
- - Adding a new option `http_compression` for sending compressed payload with the `Content-Encoding: gzip` header to the configured http endpoint #66
3
-
4
- ## 4.3.4
5
- - Docs fixes
1
+ ## 5.0.0
2
+ - Breaking: bump dependency in breaking version of logstash-mixin-http_client
6
3
 
7
4
  ## 4.3.3
8
5
  - Docs: Add plugin description.
@@ -48,7 +48,6 @@ This plugin supports the following configuration options plus the <<plugins-{typ
48
48
  | <<plugins-{type}s-{plugin}-follow_redirects>> |<<boolean,boolean>>|No
49
49
  | <<plugins-{type}s-{plugin}-format>> |<<string,string>>, one of `["json", "form", "message"]`|No
50
50
  | <<plugins-{type}s-{plugin}-headers>> |<<hash,hash>>|No
51
- | <<plugins-{type}s-{plugin}-http_compression>> |<<boolean,boolean>>|No
52
51
  | <<plugins-{type}s-{plugin}-http_method>> |<<string,string>>, one of `["put", "post", "patch", "delete", "get", "head"]`|Yes
53
52
  | <<plugins-{type}s-{plugin}-ignorable_codes>> |<<number,number>>|No
54
53
  | <<plugins-{type}s-{plugin}-keepalive>> |<<boolean,boolean>>|No
@@ -65,7 +64,6 @@ This plugin supports the following configuration options plus the <<plugins-{typ
65
64
  | <<plugins-{type}s-{plugin}-retry_non_idempotent>> |<<boolean,boolean>>|No
66
65
  | <<plugins-{type}s-{plugin}-retryable_codes>> |<<number,number>>|No
67
66
  | <<plugins-{type}s-{plugin}-socket_timeout>> |<<number,number>>|No
68
- | <<plugins-{type}s-{plugin}-ssl_certificate_validation>> |<<boolean,boolean>>|No
69
67
  | <<plugins-{type}s-{plugin}-truststore>> |a valid filesystem path|No
70
68
  | <<plugins-{type}s-{plugin}-truststore_password>> |<<password,password>>|No
71
69
  | <<plugins-{type}s-{plugin}-truststore_type>> |<<string,string>>|No
@@ -174,15 +172,6 @@ Otherwise, the event is sent as json.
174
172
  Custom headers to use
175
173
  format is `headers => ["X-My-Header", "%{host}"]`
176
174
 
177
- [id="plugins-{type}s-{plugin}-http_compression"]
178
- ===== `http_compression`
179
-
180
- * Value type is <<boolean,boolean>>
181
- * Default value is `false`
182
-
183
- Enable request compression support. With this enabled the plugin will compress
184
- http requests using gzip.
185
-
186
175
  [id="plugins-{type}s-{plugin}-http_method"]
187
176
  ===== `http_method`
188
177
 
@@ -328,15 +317,6 @@ If encountered as response codes this plugin will retry these requests
328
317
 
329
318
  Timeout (in seconds) to wait for data on the socket. Default is `10s`
330
319
 
331
- [id="plugins-{type}s-{plugin}-ssl_certificate_validation"]
332
- ===== `ssl_certificate_validation`
333
-
334
- * Value type is <<boolean,boolean>>
335
- * Default value is `true`
336
-
337
- Set this to false to disable SSL/TLS certificate validation
338
- Note: setting this to false is generally considered insecure!
339
-
340
320
  [id="plugins-{type}s-{plugin}-truststore"]
341
321
  ===== `truststore`
342
322
 
@@ -4,7 +4,6 @@ require "logstash/namespace"
4
4
  require "logstash/json"
5
5
  require "uri"
6
6
  require "logstash/plugin_mixins/http_client"
7
- require "zlib"
8
7
 
9
8
  class LogStash::Outputs::Http < LogStash::Outputs::Base
10
9
  include LogStash::PluginMixins::HttpClient
@@ -81,9 +80,6 @@ class LogStash::Outputs::Http < LogStash::Outputs::Base
81
80
  # Otherwise, the event is sent as json.
82
81
  config :format, :validate => ["json", "form", "message"], :default => "json"
83
82
 
84
- # Set this to true if you want to enable gzip compression for your http requests
85
- config :http_compression, :validate => :boolean, :default => false
86
-
87
83
  config :message, :validate => :string
88
84
 
89
85
  def register
@@ -200,12 +196,6 @@ class LogStash::Outputs::Http < LogStash::Outputs::Base
200
196
  url = event.sprintf(@url)
201
197
  headers = event_headers(event)
202
198
 
203
- # Compress the body and add appropriate header
204
- if @http_compression == true
205
- headers["Content-Encoding"] = "gzip"
206
- body = gzip(body)
207
- end
208
-
209
199
  # Create an async request
210
200
  request = client.background.send(@http_method, url, :body => body, :headers => headers)
211
201
 
@@ -310,16 +300,6 @@ class LogStash::Outputs::Http < LogStash::Outputs::Base
310
300
  end
311
301
  end
312
302
 
313
- # gzip data
314
- def gzip(data)
315
- gz = StringIO.new
316
- gz.set_encoding("BINARY")
317
- z = Zlib::GzipWriter.new(gz)
318
- z.write(data)
319
- z.close
320
- gz.string
321
- end
322
-
323
303
  def convert_mapping(mapping, event)
324
304
  if mapping.is_a?(Hash)
325
305
  mapping.reduce({}) do |acc, kv|
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-http'
3
- s.version = '4.4.0'
3
+ s.version = '5.0.0'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = "This output lets you `PUT` or `POST` events to a generic HTTP(S) 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"
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
 
21
21
  # Gem dependencies
22
22
  s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
23
- s.add_runtime_dependency "logstash-mixin-http_client", ">= 5.1.0", "< 6.0.0"
23
+ s.add_runtime_dependency "logstash-mixin-http_client", ">= 6.0.0", "< 7.0.0"
24
24
 
25
25
  s.add_development_dependency 'logstash-devutils'
26
26
  s.add_development_dependency 'sinatra'
@@ -3,7 +3,6 @@ require "logstash/outputs/http"
3
3
  require "logstash/codecs/plain"
4
4
  require "thread"
5
5
  require "sinatra"
6
- require_relative "../supports/compressed_requests"
7
6
 
8
7
  PORT = rand(65535-1024) + 1025
9
8
 
@@ -17,10 +16,8 @@ end
17
16
  #
18
17
  # == Sinatra (v1.4.6) has taken the stage on 51572 for development with backup from WEBrick
19
18
  # == Sinatra has ended his set (crowd applauds)
20
- #
19
+
21
20
  class TestApp < Sinatra::Base
22
- # on the fly uncompress gzip content
23
- use CompressedRequests
24
21
 
25
22
  # disable WEBrick logging
26
23
  def self.server_settings
@@ -41,11 +38,11 @@ class TestApp < Sinatra::Base
41
38
  def self.last_request
42
39
  @last_request
43
40
  end
44
-
41
+
45
42
  def self.retry_fail_count=(count)
46
43
  @retry_fail_count = count
47
44
  end
48
-
45
+
49
46
  def self.retry_fail_count()
50
47
  @retry_fail_count
51
48
  end
@@ -59,10 +56,10 @@ class TestApp < Sinatra::Base
59
56
  self.class.last_request = request
60
57
  [400, "YUP"]
61
58
  end
62
-
59
+
63
60
  multiroute(%w(get post put patch delete), "/retry") do
64
61
  self.class.last_request = request
65
-
62
+
66
63
  if self.class.retry_fail_count > 0
67
64
  self.class.retry_fail_count -= 1
68
65
  [429, "Will succeed in #{self.class.retry_fail_count}"]
@@ -83,7 +80,7 @@ RSpec.configure do |config|
83
80
  app.run!(opts) do |server|
84
81
  queue.push("started")
85
82
  end
86
- rescue => e
83
+ rescue => e
87
84
  puts "Error in webserver thread #{e}"
88
85
  # ignore
89
86
  end
@@ -161,7 +158,7 @@ describe LogStash::Outputs::Http do
161
158
  expect(subject).to have_received(:log_failure).with(any_args)
162
159
  end
163
160
  end
164
-
161
+
165
162
  context "with ignorable failing requests" do
166
163
  let(:url) { "http://localhost:#{port}/bad"}
167
164
  let(:verb_behavior_config) { super.merge("ignorable_codes" => [400]) }
@@ -174,7 +171,7 @@ describe LogStash::Outputs::Http do
174
171
  expect(subject).not_to have_received(:log_failure).with(any_args)
175
172
  end
176
173
  end
177
-
174
+
178
175
  context "with retryable failing requests" do
179
176
  let(:url) { "http://localhost:#{port}/retry"}
180
177
 
@@ -187,12 +184,12 @@ describe LogStash::Outputs::Http do
187
184
  it "should log a failure 2 times" do
188
185
  expect(subject).to have_received(:log_failure).with(any_args).twice
189
186
  end
190
-
187
+
191
188
  it "should make three total requests" do
192
189
  expect(subject).to have_received(:send_event).exactly(3).times
193
190
  end
194
- end
195
-
191
+ end
192
+
196
193
  end
197
194
  end
198
195
 
@@ -228,8 +225,7 @@ describe LogStash::Outputs::Http do
228
225
  end
229
226
  end
230
227
 
231
- shared_examples "integration tests" do
232
- let(:base_config) { {} }
228
+ describe "integration tests" do
233
229
  let(:url) { "http://localhost:#{port}/good" }
234
230
  let(:event) {
235
231
  LogStash::Event.new("foo" => "bar", "baz" => "bot", "user" => "McBest")
@@ -243,7 +239,7 @@ describe LogStash::Outputs::Http do
243
239
 
244
240
  describe "sending with the default (JSON) config" do
245
241
  let(:config) {
246
- base_config.merge({"url" => url, "http_method" => "post", "pool_max" => 1})
242
+ {"url" => url, "http_method" => "post", "pool_max" => 1}
247
243
  }
248
244
  let(:expected_body) { LogStash::Json.dump(event) }
249
245
  let(:expected_content_type) { "application/json" }
@@ -253,7 +249,7 @@ describe LogStash::Outputs::Http do
253
249
 
254
250
  describe "sending the event as a form" do
255
251
  let(:config) {
256
- base_config.merge({"url" => url, "http_method" => "post", "pool_max" => 1, "format" => "form"})
252
+ {"url" => url, "http_method" => "post", "pool_max" => 1, "format" => "form"}
257
253
  }
258
254
  let(:expected_body) { subject.send(:encode, event.to_hash) }
259
255
  let(:expected_content_type) { "application/x-www-form-urlencoded" }
@@ -263,7 +259,7 @@ describe LogStash::Outputs::Http do
263
259
 
264
260
  describe "sending the event as a message" do
265
261
  let(:config) {
266
- base_config.merge({"url" => url, "http_method" => "post", "pool_max" => 1, "format" => "message", "message" => "%{foo} AND %{baz}"})
262
+ {"url" => url, "http_method" => "post", "pool_max" => 1, "format" => "message", "message" => "%{foo} AND %{baz}"}
267
263
  }
268
264
  let(:expected_body) { "#{event.get("foo")} AND #{event.get("baz")}" }
269
265
  let(:expected_content_type) { "text/plain" }
@@ -273,7 +269,7 @@ describe LogStash::Outputs::Http do
273
269
 
274
270
  describe "sending a mapped event" do
275
271
  let(:config) {
276
- base_config.merge({"url" => url, "http_method" => "post", "pool_max" => 1, "mapping" => {"blah" => "X %{foo}"} })
272
+ {"url" => url, "http_method" => "post", "pool_max" => 1, "mapping" => {"blah" => "X %{foo}"} }
277
273
  }
278
274
  let(:expected_body) { LogStash::Json.dump("blah" => "X #{event.get("foo")}") }
279
275
  let(:expected_content_type) { "application/json" }
@@ -283,7 +279,7 @@ describe LogStash::Outputs::Http do
283
279
 
284
280
  describe "sending a mapped, nested event" do
285
281
  let(:config) {
286
- base_config.merge({
282
+ {
287
283
  "url" => url,
288
284
  "http_method" => "post",
289
285
  "pool_max" => 1,
@@ -296,7 +292,7 @@ describe LogStash::Outputs::Http do
296
292
  "user" => "Z %{user}"
297
293
  }]
298
294
  }
299
- })
295
+ }
300
296
  }
301
297
  let(:expected_body) {
302
298
  LogStash::Json.dump({
@@ -314,14 +310,4 @@ describe LogStash::Outputs::Http do
314
310
  include_examples("a received event")
315
311
  end
316
312
  end
317
-
318
- describe "integration test without gzip compression" do
319
- include_examples("integration tests")
320
- end
321
-
322
- describe "integration test with gzip compression" do
323
- include_examples("integration tests") do
324
- let(:base_config) { { "http_compression" => true } }
325
- end
326
- end
327
313
  end
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: 4.4.0
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-23 00:00:00.000000000 Z
11
+ date: 2017-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -35,10 +35,10 @@ dependencies:
35
35
  requirements:
36
36
  - - ">="
37
37
  - !ruby/object:Gem::Version
38
- version: 5.1.0
38
+ version: 6.0.0
39
39
  - - "<"
40
40
  - !ruby/object:Gem::Version
41
- version: 6.0.0
41
+ version: 7.0.0
42
42
  name: logstash-mixin-http_client
43
43
  prerelease: false
44
44
  type: :runtime
@@ -46,10 +46,10 @@ dependencies:
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 5.1.0
49
+ version: 6.0.0
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: 6.0.0
52
+ version: 7.0.0
53
53
  - !ruby/object:Gem::Dependency
54
54
  requirement: !ruby/object:Gem::Requirement
55
55
  requirements:
@@ -108,7 +108,6 @@ files:
108
108
  - lib/logstash/outputs/http.rb
109
109
  - logstash-output-http.gemspec
110
110
  - spec/outputs/http_spec.rb
111
- - spec/supports/compressed_requests.rb
112
111
  homepage: http://www.elastic.co/guide/en/logstash/current/index.html
113
112
  licenses:
114
113
  - Apache License (2.0)
@@ -137,4 +136,3 @@ specification_version: 4
137
136
  summary: This output lets you `PUT` or `POST` events to a generic HTTP(S) endpoint
138
137
  test_files:
139
138
  - spec/outputs/http_spec.rb
140
- - spec/supports/compressed_requests.rb
@@ -1,38 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- # based on relistan's rack handler
4
- # out of the box rack only gives use the rack deflater handler to return compressed
5
- # response, this gist offer the inverse and should work on all rack based app like sinatra or rails.
6
- #
7
- # original source: https://gist.github.com/relistan/2109707
8
- require "zlib"
9
-
10
- class CompressedRequests
11
- def initialize(app)
12
- @app = app
13
- end
14
-
15
- def encoding_handled?(env)
16
- ['gzip', 'deflate'].include? env['HTTP_CONTENT_ENCODING']
17
- end
18
-
19
- def call(env)
20
- if encoding_handled?(env)
21
- extracted = decode(env['rack.input'], env['HTTP_CONTENT_ENCODING'])
22
-
23
- env.delete('HTTP_CONTENT_ENCODING')
24
- env['CONTENT_LENGTH'] = extracted.bytesize
25
- env['rack.input'] = StringIO.new(extracted)
26
- end
27
-
28
- status, headers, response = @app.call(env)
29
- return [status, headers, response]
30
- end
31
-
32
- def decode(input, content_encoding)
33
- case content_encoding
34
- when 'gzip' then Zlib::GzipReader.new(input).read
35
- when 'deflate' then Zlib::Inflate.inflate(input.read)
36
- end
37
- end
38
- end